Add highlighting, fixed len instructions and more
This commit is contained in:
22
cpu/core.c
22
cpu/core.c
@@ -34,11 +34,22 @@ void step(CPU *cpu) {
|
||||
cpu->mode |= CPU_MODE_HALTED;
|
||||
}
|
||||
}
|
||||
uint8_t opcode = read_mem(cpu, cpu->pc++);
|
||||
uint8_t reg1, reg2, imm, temp, temp2;
|
||||
uint32_t newPC, addrTemp;
|
||||
uint32_t newPC, addrTemp, oldPC;
|
||||
int32_t cmpResult;
|
||||
|
||||
oldPC = cpu->pc;
|
||||
newPC = oldPC;
|
||||
|
||||
uint8_t opcode = read_mem(cpu, cpu->pc++);
|
||||
|
||||
|
||||
const uint32_t differenceAlignment = oldPC % CPU_INSTRUCTION_SIZE;
|
||||
|
||||
if (differenceAlignment) {
|
||||
cpu->pc += differenceAlignment;
|
||||
}
|
||||
|
||||
switch (opcode) {
|
||||
case NOP:
|
||||
//Don't do anything
|
||||
@@ -491,5 +502,12 @@ void step(CPU *cpu) {
|
||||
printf("Unknown opcode: %d\n", opcode);
|
||||
cpu->mode |= CPU_MODE_ERROR;
|
||||
}
|
||||
if (oldPC == newPC) {
|
||||
const uint32_t remainingBytes = CPU_INSTRUCTION_SIZE - (cpu->pc - oldPC);
|
||||
if (remainingBytes > CPU_INSTRUCTION_SIZE) {
|
||||
printf("HELP, INSTRUCTION SIZE SMALLER THAN INSTRUCTION");
|
||||
}
|
||||
cpu->pc += remainingBytes;
|
||||
}
|
||||
cpu->cycle++;
|
||||
}
|
Reference in New Issue
Block a user