inital commit кек
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"opcode": 0,
|
||||
"mnemonic": "NOP",
|
||||
"args": [],
|
||||
"cycles": 1,
|
||||
"semantics": [
|
||||
{"op": "nop"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 1,
|
||||
"mnemonic": "MOV_A_B",
|
||||
"cycles": 1,
|
||||
"semantics": [
|
||||
{"op": "copy", "from": "b", "to": "a"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 2,
|
||||
"mnemonic": "MOV_IMM_A",
|
||||
"cycles": 1,
|
||||
"semantics": [
|
||||
{"op": "load_imm", "to": "a", "value": "$next"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 3,
|
||||
"mnemonic": "ADD_A_B",
|
||||
"cycles": 2,
|
||||
"semantics": [
|
||||
{"op": "add", "from": "b", "to": "a", "result": "a"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 4,
|
||||
"mnemonic": "SUB_A_B",
|
||||
"cycles": 2,
|
||||
"semantics": [
|
||||
{"op": "sub", "from": "a", "to": "b", "result": "a"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 5,
|
||||
"mnemonic": "JMP_A",
|
||||
"cycles": 2,
|
||||
"semantics": [
|
||||
{"op": "jmp", "to": "a"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 6,
|
||||
"mnemonic": "JZ_A",
|
||||
"cycles": 2,
|
||||
"semantics": [
|
||||
{"op": "jcc", "to": "a", "condition": "zero,1"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 7,
|
||||
"mnemonic": "JC_A",
|
||||
"cycles": 2,
|
||||
"semantics": [
|
||||
{"op": "jcc", "to": "a", "condition": "carry,1"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 8,
|
||||
"mnemonic": "CMP_A_B",
|
||||
"cycles": 1,
|
||||
"semantics": [
|
||||
{"op": "cmp", "from": "a", "to": "b"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 9,
|
||||
"mnemonic": "MOV_IMM_B",
|
||||
"cycles": 1,
|
||||
"semantics": [
|
||||
{"op": "load_imm", "to": "b", "value": "$next"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 10,
|
||||
"mnemonic": "STORE_A",
|
||||
"cycles": 2,
|
||||
"semantics": [
|
||||
{"op": "store", "from": "a", "to": "mem[$next]"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 11,
|
||||
"mnemonic": "LOAD_A",
|
||||
"cycles": 2,
|
||||
"semantics": [
|
||||
{"op": "load", "from": "mem[$next]", "to": "a"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 12,
|
||||
"mnemonic": "JMP_IMM",
|
||||
"cycles": 2,
|
||||
"semantics": [
|
||||
{"op": "jmp_imm"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 13,
|
||||
"mnemonic": "JZ_IMM",
|
||||
"cycles": 2,
|
||||
"semantics": [
|
||||
{"op": "jcc_imm", "condition": "zero,1"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 14,
|
||||
"mnemonic": "JC_IMM",
|
||||
"cycles": 2,
|
||||
"semantics": [
|
||||
{"op": "jcc_imm", "condition": "carry,1"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 15,
|
||||
"mnemonic": "INC_A",
|
||||
"cycles": 1,
|
||||
"semantics": [
|
||||
{"op": "inc", "from": "a", "to": "a"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 16,
|
||||
"mnemonic": "CALL_IMM",
|
||||
"cycles": 3,
|
||||
"semantics": [
|
||||
{"op": "call", "to": "$next"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"opcode": 17,
|
||||
"mnemonic": "RET",
|
||||
"cycles": 2,
|
||||
"semantics": [
|
||||
{"op": "ret"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"opcode": 255,
|
||||
"mnemonic": "HLT",
|
||||
"args": [],
|
||||
"cycles": 1,
|
||||
"semantics": [
|
||||
{"op": "nop"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"memory_read": [0x01, 0x00],
|
||||
"memory_write": [0x02, 0x00],
|
||||
"io_read": [0x03],
|
||||
"io_write": [0x04]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "AsmDemoCPU",
|
||||
"arch": "tiny-8bit",
|
||||
"module_type": "cpu",
|
||||
"version": 1,
|
||||
"tdp": 5.0,
|
||||
"memory_size": 65536,
|
||||
"frequency": 1000000,
|
||||
"description": "ASM-programmed TinyCPU demo"
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
; Hello World for TinyCPU
|
||||
; Prints "Hello!" to GPU via 0xC0
|
||||
;
|
||||
; TinyCPU instructions:
|
||||
; 0x00 NOP 0x01 MOV_A_B 0x02 MOV_IMM_A 0x03 ADD_A_B
|
||||
; 0x04 SUB_A_B 0x05 JMP_A 0x06 JZ_A 0x07 JC_A
|
||||
; 0x08 CMP_A_B 0x09 MOV_IMM_B 0x0A STORE_A 0x0B LOAD_A
|
||||
; 0x0C JMP_IMM 0x0D JZ_IMM 0x0E JC_IMM 0x0F INC_A
|
||||
; 0x10 CALL_IMM 0x11 RET 0xFF HLT
|
||||
|
||||
.org 0x00
|
||||
|
||||
; Print "Hello!"
|
||||
MOV_IMM_A 0x48 ; 'H'
|
||||
STORE_A 0xC0
|
||||
MOV_IMM_A 0x65 ; 'e'
|
||||
STORE_A 0xC0
|
||||
MOV_IMM_A 0x6C ; 'l'
|
||||
STORE_A 0xC0
|
||||
MOV_IMM_A 0x6C ; 'l'
|
||||
STORE_A 0xC0
|
||||
MOV_IMM_A 0x6F ; 'o'
|
||||
STORE_A 0xC0
|
||||
MOV_IMM_A 0x21 ; '!'
|
||||
STORE_A 0xC0
|
||||
MOV_IMM_A 0x0A ; newline
|
||||
STORE_A 0xC0
|
||||
|
||||
loop:
|
||||
MOV_IMM_A 0x41 ; 'A'
|
||||
print_loop:
|
||||
STORE_A 0xC0 ; print char
|
||||
INC_A ; next char
|
||||
MOV_IMM_B 0x5B ; b = 'Z' + 1
|
||||
CMP_A_B ; compare
|
||||
JZ_IMM done ; if A == 0x5B, done
|
||||
JMP_IMM print_loop
|
||||
|
||||
done:
|
||||
MOV_IMM_A 0x0A ; newline
|
||||
STORE_A 0xC0
|
||||
HLT
|
||||
@@ -0,0 +1,30 @@
|
||||
// Hello World for TinyCPU (C-style)
|
||||
// Prints "Hello from C!" to the GPU display
|
||||
// Compile: cbecc ccompile program.c -o roms/boot.bin --arch tinycpu
|
||||
|
||||
// GPU output port address
|
||||
#define GPU_OUT 0xC0
|
||||
|
||||
// Output a character to the GPU display
|
||||
void write_gpu(char c) {
|
||||
// Will be translated to: MOV_IMM_A c; STORE_A 0xC0
|
||||
}
|
||||
|
||||
int main() {
|
||||
write_gpu('H');
|
||||
write_gpu('e');
|
||||
write_gpu('l');
|
||||
write_gpu('l');
|
||||
write_gpu('o');
|
||||
write_gpu(' ');
|
||||
write_gpu('f');
|
||||
write_gpu('r');
|
||||
write_gpu('o');
|
||||
write_gpu('m');
|
||||
write_gpu(' ');
|
||||
write_gpu('C');
|
||||
write_gpu('!');
|
||||
write_gpu('\n');
|
||||
|
||||
return 0; // HLT
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// C++ demo for TinyCPU
|
||||
// Prints numbers 0-9 to GPU
|
||||
extern "C" void write_gpu(char c);
|
||||
|
||||
int main() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
write_gpu('0' + i);
|
||||
write_gpu('\n');
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
; Example hex machine code for TinyCPU
|
||||
; Prints "CPU!" to the GPU display via port 0xC0
|
||||
02 43 0A C0 ; MOV_IMM_A 'C', STORE_A 0xC0
|
||||
02 50 0A C0 ; MOV_IMM_A 'P', STORE_A 0xC0
|
||||
02 55 0A C0 ; MOV_IMM_A 'U', STORE_A 0xC0
|
||||
02 21 0A C0 ; MOV_IMM_A '!', STORE_A 0xC0
|
||||
02 0A 0A C0 ; MOV_IMM_A '\n', STORE_A 0xC0
|
||||
FF ; HLT
|
||||
@@ -0,0 +1,6 @@
|
||||
# Example Python program for TinyCPU
|
||||
# Translates to bytecode that writes to GPU
|
||||
# Variables are stored starting at address 0x20
|
||||
|
||||
# Print characters to the GPU
|
||||
print("Hello!")
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"a": 0,
|
||||
"b": 0,
|
||||
"c": 0,
|
||||
"d": 0,
|
||||
"pc": 0,
|
||||
"sp": 0,
|
||||
"carry": 0,
|
||||
"zero": 0
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
H
|
||||
Àe
|
||||
Àl
|
||||
Àl
|
||||
Ào
|
||||
À!
|
||||
À
|
||||
|
||||
ÀA
|
||||
À [
|
||||
|
||||
|
||||
Reference in New Issue
Block a user