fix doc + add 8 regs
This commit is contained in:
@@ -20,7 +20,7 @@ make
|
|||||||
|
|
||||||
- 8-bit processing unit
|
- 8-bit processing unit
|
||||||
- RISC (reduced instruction set computer)
|
- RISC (reduced instruction set computer)
|
||||||
- 4 general purpose registers (labeled R0 to R3)
|
- 8 general purpose registers (labeled Rx)
|
||||||
- 1 input port, 1 output port (via getchar and putchar)
|
- 1 input port, 1 output port (via getchar and putchar)
|
||||||
- Turing-completeness: bitwise and arithmetic operations
|
- Turing-completeness: bitwise and arithmetic operations
|
||||||
|
|
||||||
@@ -33,9 +33,11 @@ MOV RX, RY
|
|||||||
; Put value X in register RX
|
; Put value X in register RX
|
||||||
PUT RX, X
|
PUT RX, X
|
||||||
|
|
||||||
; Arithmetic addition and substraction stored in RX
|
; Arithmetic operations. Result stored in RX
|
||||||
ADD RX, RY
|
ADD RX, RY
|
||||||
SUB RX, RY
|
SUB RX, RY
|
||||||
|
MUL RX, RY
|
||||||
|
DIV RX, RY
|
||||||
|
|
||||||
; Bitwise operations stored in RX
|
; Bitwise operations stored in RX
|
||||||
OR RX, RY
|
OR RX, RY
|
||||||
|
|||||||
6
cpu.c
6
cpu.c
@@ -196,10 +196,10 @@ void cpu_run()
|
|||||||
void cpu_dump()
|
void cpu_dump()
|
||||||
{
|
{
|
||||||
printf("\n*** CPU state dump ***\nPC: 0x%x\nEqual flag: %d\nHalted: %d\n\n", cpu.pc, cpu.equal_flag, cpu.halted);
|
printf("\n*** CPU state dump ***\nPC: 0x%x\nEqual flag: %d\nHalted: %d\n\n", cpu.pc, cpu.equal_flag, cpu.halted);
|
||||||
|
|
||||||
for (size_t i=0; i<NUM_REGISTERS; i++)
|
for (size_t i=1; i<NUM_REGISTERS; i+=2)
|
||||||
{
|
{
|
||||||
printf("R%lu: 0x%x\n", i, cpu.reg[i]);
|
printf("R%lu: 0x%04x R%lu: 0x%04x\n", i, cpu.reg[i], i+1, cpu.reg[i+1]);
|
||||||
}
|
}
|
||||||
puts("");
|
puts("");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user