Krolyxon
Commit 5d34df5

Branches

Tags

Refs →

bench515d34df5

modify README.md

Author
krolxon
Date
2026-01-08 21:48 +0530
Parent
467ec78
Commit
5d34df5e38802da8da8d6ce13963fed489893c7a

+72 −29

1 file changed

  1. M README.md +72 −29
M README.md View
@@ -1,10 +1,46 @@
11 # 8-Bit CPU Emulator
22
3−## CPU Architecture
4−- Word Size
5− - **Data Width:** 8 bits
6− - **Address width:** 16 bits
7− - **Address space:** 64 KB (0x0000-0xFFFF)
3+This project is an educational 8-bit CPU emulator written in Rust, it's build to understand core computer architecture concepts such as instruction sets, flags,
4+control flow, stacks and system calls.
5+
6+This project is **not** a production CPU and **not** accurate. It is designed purely for learning and experimentation.
7+
8+-----
9+
10+## Features
11+
12+- Custom 8-bit ISA (control-flow and arithmetic operations)
13+- 4 general-purpose registers
14+- 64 KB (0x0000-0xFFFF) byte-addressable memory
15+- Two-pass assembler with label support
16+- Stack-based function calls
17+- Stack is software-managed and grows downward
18+
19+---
20+
21+
22+
23+## Registers
24+| Register | Size | Description |
25+| -------- | ------ | ------------------------------ |
26+| A | 8-bit | General-purpose register |
27+| B | 8-bit | General-purpose register |
28+| C | 8-bit | General-purpose register |
29+| D | 8-bit | General-purpose register |
30+| PC | 16-bit | Program Counter |
31+| SP | 16-bit | Stack pointer |
32+
33+
34+## Flags Register
35+
36+The CPU maintains a small flags register.
37+
38+| Flag | Description |
39+| ----- | ------------ |
40+| Z | Zero flag - set if last result was `0` |
41+| C | Carry/Borrow flag |
42+
43+- Control-flow instructions do **not** modify flags.
844
945 ## Supported Instructions
1046
@@ -21,41 +57,48 @@
2157 | DIV | div r1, r2 |
2258 | CALL | call \<label\> |
2359 | SYS | sys \<syscall_no\> |
24−| HLT (Halt) | hlt |
25−
26−
27−## Registers
28−| Register | Size | Description |
29−| -------- | ------ | ------------------------------ |
30−| A | 8-bit | General |
31−| B | 8-bit | General |
32−| C | 8-bit | General |
33−| D | 8-bit | General |
34−| PC | 16-bit | Program Counter |
35−| SP | 16-bit | Stack pointer |
36−
37−
38−## Flags
39−| Flag | Description |
40−| ----- | ------------ |
41−| Z | Zero Flag |
42−| C | Carry/Borrow |
43−
60+| HLT (Halt) | hlt |
4461
4562 ## Syscalls
63+
4664 | Imm | Meaning |
4765 | --- | ------- |
4866 | 0 | Exit Program |
4967 | 1 | Print register A as integer |
5068 | 2 | Print register A as ASCII char |
5169
70+- Syscalls also do not modify flags
71+
72+## Example assembly program
73+
74+```assembly
75+mov b, 3
76+mov a, 1
77+
78+loop:
79+ sub b, a
80+ jnz loop
81+
82+sys 1 ; print register A
83+sys 0 ; exit
84+```
85+
86+## Usage
5287
53−# Usage
5488 ```bash
5589 cargo run -- --f <examples/filename.asc>
5690 ```
5791
58−## Todo
92+## Non-goals
93+
94+1. No pipelining
95+2. No interrupts
96+3. No virtual memory
97+4. No privilege levels
98+5. No hardware I/O
99+
100+## Goals
101+
59102 - [x] Assembler
60103 - [x] Lexer/Tokenizer
61104 - [x] Add label support (supporting JMP/JZ/JNZ)
@@ -66,5 +109,5 @@ cargo run -- --f <examples/filename.asc>
66109 - [x] CALL
67110 - [x] RET
68111 - [x] SYS
69−- [ ] Better Error handling
70−- [ ] TUI Debugger
112+- [ ] Better error-handling
113+- [ ] TUI debugger