xor di and cpu flags

This commit is contained in:
2025-01-30 18:38:29 -07:00
parent 6a82e9fa03
commit 1bf98447a3
6 changed files with 38 additions and 9 deletions

View File

@ -5,6 +5,7 @@ cpu_context ctx = {0};
void cpu_init() {
ctx.regs.pc = 0x100;
ctx.regs.a = 0x01;
}
static void fetch_instruction() {
@ -38,7 +39,7 @@ static void fetch_data() {
return;
}
default:
printf("Unknown Addressing Mode! %d\n", ctx.cur_inst->mode);
printf("Unknown Addressing Mode! %d (%02X)\n", ctx.cur_inst->mode, ctx.cur_opcode);
exit(-7);
return;
}
@ -60,7 +61,7 @@ bool cpu_step() {
u16 pc = ctx.regs.pc;
fetch_instruction();
fetch_data();
printf("%04X: %7s (%02X %02X %02X) A: %02X B: %02X C: %02X\n", pc, ctx.cur_inst != NULL ? inst_name(ctx.cur_inst->type) : "UNK", ctx.cur_opcode, bus_read(pc+1), bus_read(pc+2), ctx.regs.a, ctx.regs.b, ctx.regs.c);
printf("%04X: %-7s (%02X %02X %02X) A: %02X B: %02X C: %02X\n", pc, inst_name(ctx.cur_inst->type), ctx.cur_opcode, bus_read(pc+1), bus_read(pc+2), ctx.regs.a, ctx.regs.b, ctx.regs.c);
if(ctx.cur_inst == NULL){
printf("Unknown Instruction! %02X\n", ctx.cur_opcode);
exit(-7);