fix R0 bug
This commit is contained in:
@@ -69,4 +69,4 @@ HLT
|
||||
|
||||
## Known bugs
|
||||
|
||||
- R0 is not usable (confusion with NOP opcode 0 in memory)
|
||||
- None for now? If you find one, please open an issue.
|
||||
|
||||
2
cpu.c
2
cpu.c
@@ -197,7 +197,7 @@ 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);
|
||||
|
||||
for (size_t i=1; i<NUM_REGISTERS; i+=2)
|
||||
for (size_t i=0; i<NUM_REGISTERS; i+=2)
|
||||
{
|
||||
printf("R%lu: 0x%04x R%lu: 0x%04x\n", i, cpu.reg[i], i+1, cpu.reg[i+1]);
|
||||
}
|
||||
|
||||
6
cpu.h
6
cpu.h
@@ -13,9 +13,6 @@
|
||||
|
||||
typedef enum
|
||||
{
|
||||
// 0x00 -> No operation
|
||||
NOP = 0,
|
||||
|
||||
// 0xA? -> Memory operations
|
||||
MOV = 0xA0,
|
||||
PUT = 0xA1,
|
||||
@@ -41,12 +38,13 @@ typedef enum
|
||||
CMP = 0xE2,
|
||||
|
||||
// 0xF? -> Misc operations
|
||||
NOP = 0xFE,
|
||||
HLT = 0xFF
|
||||
} instruction_set_t;
|
||||
|
||||
/*
|
||||
* CPU structure definition
|
||||
* Contains 4 8-bit registers, memory, a program counter, a halt switch, and flags.
|
||||
* Contains 8-bit registers, memory, a program counter, a halt switch, and flags.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
;this is a comment
|
||||
PUT R2, 5
|
||||
PUT R0, 5
|
||||
PUT R3, 2
|
||||
DIV R2, R3
|
||||
ADD R0, R3
|
||||
|
||||
HLT
|
||||
|
||||
Reference in New Issue
Block a user