CPU testing
This commit is contained in:
11
lib/cpu.c
11
lib/cpu.c
@ -3,6 +3,7 @@
|
||||
#include <common.h>
|
||||
#include <emu.h>
|
||||
#include <interrupts.h>
|
||||
#include <dbg.h>
|
||||
|
||||
cpu_context ctx = {0};
|
||||
|
||||
@ -39,11 +40,19 @@ bool cpu_step() {
|
||||
ctx.regs.f & (1 << 5) ? 'H' : '-',
|
||||
ctx.regs.f & (1 << 4) ? 'C' : '-'
|
||||
);
|
||||
printf("%08lX - %04X: %-7s (%02X %02X %02X) A: %02X F: %s BC: %02X%02X DE: %02X%02X HL: %02X%02X SP: %04X PC: %04X\n", emu_get_context()->ticks, pc, inst_name(ctx.cur_inst->type), ctx.cur_opcode, bus_read(pc+1), bus_read(pc+2), ctx.regs.a, flags, ctx.regs.b, ctx.regs.c, ctx.regs.d, ctx.regs.e, ctx.regs.h, ctx.regs.l, ctx.regs.sp, ctx.regs.pc);
|
||||
|
||||
char inst[16];
|
||||
inst_to_str(&ctx, inst);
|
||||
|
||||
printf("%08lX - %04X: %-12s (%02X %02X %02X) A: %02X F: %s BC: %02X%02X DE: %02X%02X HL: %02X%02X SP: %04X PC: %04X\n", emu_get_context()->ticks, pc, inst, ctx.cur_opcode, bus_read(pc+1), bus_read(pc+2), ctx.regs.a, flags, ctx.regs.b, ctx.regs.c, ctx.regs.d, ctx.regs.e, ctx.regs.h, ctx.regs.l, ctx.regs.sp, ctx.regs.pc);
|
||||
if(ctx.cur_inst == NULL){
|
||||
printf("Unknown Instruction! %02X\n", ctx.cur_opcode);
|
||||
exit(-7);
|
||||
}
|
||||
|
||||
dbg_update();
|
||||
dbg_print();
|
||||
|
||||
execute();
|
||||
} else {
|
||||
//is halted
|
||||
|
Reference in New Issue
Block a user