| 1 | # 8-Bit CPU Emulator |
| 2 | |
| 3 | ## CPU Architecture |
| 4 | - Word Size |
| 5 | - **Data Width:** 8 bits |
| 6 | - **Address width:** 16 bits |
| 7 | - **Address space:** 64 KB (0x0000-0xFFFF) |
| 8 | |
| 9 | ## Supported Instructions |
| 10 | |
| 11 | | Instruction | Syntax (Reg-Reg) | Syntax (Reg-Imm) | |
| 12 | | ----------- | ---------------- | ---------------- | |
| 13 | | MOV | mov dest, src | mov reg, imm | |
| 14 | | ADD | add r1, r2 | add reg, imm | |
| 15 | | SUB | sub r1, r2 | sub reg, imm | |
| 16 | | JMP | jmp addr | jmp addr | |
| 17 | | JZ | jz addr | jz addr | |
| 18 | | JNZ | jnz addr | jnz addr | |
| 19 | | CMP | cmp reg, reg | cmp reg, imp | |
| 20 | | HLT (Halt) | hlt | hlt | |
| 21 | |
| 22 | ## Registers |
| 23 | | Register | Size | Description | |
| 24 | | -------- | ------ | ------------------------------ | |
| 25 | | A | 8-bit | General | |
| 26 | | B | 8-bit | General | |
| 27 | | C | 8-bit | General | |
| 28 | | D | 8-bit | General | |
| 29 | | PC | 16-bit | Program Counter | |
| 30 | | SP | 16-bit | Stack pointer (unused for now) | |
| 31 | |
| 32 | ## Flags |
| 33 | | Flag | Description | |
| 34 | | ----- | ------------ | |
| 35 | | Z | Zero Flag | |
| 36 | | C | Carry/Borrow | |
| 37 | |
| 38 | |
| 39 | # Usage |
| 40 | ```bash |
| 41 | cargo run -- --f <examples/filename.asc> |
| 42 | ``` |
| 43 | |
| 44 | ## Todo |
| 45 | - [x] Assembler |
| 46 | - [x] Lexer/Tokenizer |
| 47 | - [x] Add label support (supporting JMP/JZ/JNZ) |
| 48 | - [ ] Add instructions |
| 49 | - [x] CMP |
| 50 | - [x] MUL |
| 51 | - [x] DIV |
| 52 | - [ ] CALL |
| 53 | - [ ] RET |
| 54 | - [ ] Error handling |
| 55 | - [ ] Build Debugger |