aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: d5fc6445c2cb4095d4001fdafb348d1dccba5a89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# 8-Bit CPU Emulator

## CPU Architecture
- Word Size
    - **Data Width:** 8 bits
    - **Address width:** 16 bits
    - **Address space:** 64 KB (0x0000-0xFFFF)

## Supported Instructions

| Instruction | Syntax       |
| ----------- | ------------ |
| MOV         | mov reg, imm OR mov reg, reg |
| ADD         | add reg, imm OR add r1, r2   |
| SUB         | sub reg, imm OR add r1, r2   |
| JMP         | jmp addr     |
| JZ          | jz addr      |
| JNZ         | jnz addr     |
| CMP         | cmp reg, imm OR cmp reg, reg     |
| HLT (Halt)  | hlt          |


## Registers
| Register | Size   | Description                    |
| -------- | ------ | ------------------------------ |
| A        | 8-bit  | General                        |
| B        | 8-bit  | General                        |
| C        | 8-bit  | General                        |
| D        | 8-bit  | General                        |
| PC       | 16-bit | Program Counter                |
| SP       | 16-bit | Stack pointer (unused for now) |

## Flags
| Flag  | Description  |
| ----- | ------------ |
| Z     | Zero Flag    |
| C     | Carry/Borrow |


# Usage
```bash
cargo run -- --f <examples/filename.asc>
```

## Todo
- [x] Assembler
    - [x] Lexer/Tokenizer
    - [x] Add label support (supporting JMP/JZ/JNZ)
- [ ] Add instructions
    - [x] CMP
    - [ ] CALL
    - [ ] RET
- [ ] Error handling
- [ ] Build Debugger