mirror of
https://github.com/pevans/erc-c.git
synced 2024-11-16 09:07:05 +00:00
Add step command
This commit is contained in:
parent
01f230dc85
commit
e50fda62be
@ -82,6 +82,7 @@ extern DEBUG_CMD(printaddr);
|
||||
extern DEBUG_CMD(printstate);
|
||||
extern DEBUG_CMD(quit);
|
||||
extern DEBUG_CMD(resume);
|
||||
extern DEBUG_CMD(step);
|
||||
extern DEBUG_CMD(unbreak);
|
||||
extern DEBUG_CMD(writeaddr);
|
||||
extern DEBUG_CMD(writestate);
|
||||
|
@ -351,6 +351,10 @@ apple2_run_loop(apple2 *mach)
|
||||
vm_reflect_pause(NULL);
|
||||
|
||||
while (vm_screen_active(mach->screen)) {
|
||||
if (vm_debug_broke(mach->cpu->PC)) {
|
||||
mach->paused = true;
|
||||
}
|
||||
|
||||
// If we're paused, then just re-loop until we're not
|
||||
if (mach->paused) {
|
||||
char *input = vm_debug_prompt();
|
||||
|
@ -33,8 +33,7 @@ REFLECT(apple2_reflect_cpu_info)
|
||||
mos6502 *cpu = (mos6502 *)vm_di_get(VM_CPU);
|
||||
FILE *out = (FILE *)vm_di_get(VM_OUTPUT);
|
||||
|
||||
fprintf(out, "REGISTERS:\n");
|
||||
fprintf(out, " A:%02x X:%02x Y:%02x P:%02x S:%02x PC:%04x\n",
|
||||
fprintf(out, "CPU: A:%02x X:%02x Y:%02x P:%02x S:%02x PC:%04x\n",
|
||||
cpu->A, cpu->X, cpu->Y, cpu->P, cpu->S, cpu->PC);
|
||||
}
|
||||
|
||||
@ -48,12 +47,9 @@ REFLECT(apple2_reflect_machine_info)
|
||||
apple2 *mach = (apple2 *)vm_di_get(VM_MACHINE);
|
||||
FILE *out = (FILE *)vm_di_get(VM_OUTPUT);
|
||||
|
||||
fprintf(out, "MACHINE:\n");
|
||||
fprintf(out, " display_mode: %02x\n", mach->display_mode);
|
||||
fprintf(out, " color_mode: %02x\n", mach->color_mode);
|
||||
fprintf(out, " bank_switch: %02x\n", mach->bank_switch);
|
||||
fprintf(out, " memory_mode: %02x\n", mach->memory_mode);
|
||||
fprintf(out, " strobe: %02x\n", mach->strobe);
|
||||
fprintf(out, "MACH: BS:%02x CM:%02x DM:%02x MM:%02x STROBE:%02x\n",
|
||||
mach->bank_switch, mach->color_mode, mach->display_mode,
|
||||
mach->memory_mode, mach->strobe);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -364,6 +364,8 @@ mos6502_execute(mos6502 *cpu)
|
||||
mos6502_address_resolver resolver;
|
||||
mos6502_instruction_handler handler;
|
||||
|
||||
// We shouldn't normally get here, if there was a breakpoint, but we
|
||||
// will in testing.
|
||||
if (vm_debug_broke(cpu->PC)) {
|
||||
return;
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ vm_debug_cmd cmdtable[] = {
|
||||
"Quit the emulator", },
|
||||
{ "resume", "r", vm_debug_cmd_resume, 0, "",
|
||||
"Resume execution", },
|
||||
{ "step", "s", vm_debug_cmd_step, 0, "",
|
||||
"Execute the current opcode and break at the next", },
|
||||
{ "unbreak", "u", vm_debug_cmd_unbreak, 1, "<addr>",
|
||||
"Remove breakpoint at <addr>", },
|
||||
{ "writeaddr", "wa", vm_debug_cmd_writeaddr, 2, "<addr> <byte>",
|
||||
@ -311,3 +313,12 @@ DEBUG_CMD(unbreak)
|
||||
{
|
||||
vm_debug_unbreak(args->addr1);
|
||||
}
|
||||
|
||||
DEBUG_CMD(step)
|
||||
{
|
||||
mos6502 *cpu = (mos6502 *)vm_di_get(VM_CPU);
|
||||
|
||||
vm_debug_unbreak(cpu->PC);
|
||||
mos6502_execute(cpu);
|
||||
vm_debug_break(cpu->PC);
|
||||
}
|
||||
|
@ -212,4 +212,25 @@ Test(vm_debug, unbreak_all)
|
||||
cr_assert_eq(vm_debug_broke(55555), false);
|
||||
}
|
||||
|
||||
Test(vm_debug, cmd_step)
|
||||
{
|
||||
// Just setting us up with some NOPs for the testing
|
||||
mos6502_set(mach->cpu, 0, 0xEA);
|
||||
mos6502_set(mach->cpu, 1, 0xEA);
|
||||
mos6502_set(mach->cpu, 2, 0xEA);
|
||||
mos6502_set(mach->cpu, 3, 0xEA);
|
||||
|
||||
vm_debug_break(1);
|
||||
mos6502_execute(mach->cpu);
|
||||
cr_assert_eq(mach->cpu->PC, 1);
|
||||
|
||||
// We should go nowhere here
|
||||
mos6502_execute(mach->cpu);
|
||||
cr_assert_eq(mach->cpu->PC, 1);
|
||||
|
||||
// Step should a) unbreak at PC, b) execute at PC
|
||||
vm_debug_cmd_step(&args);
|
||||
cr_assert_eq(mach->cpu->PC, 2);
|
||||
}
|
||||
|
||||
/* Test(vm_debug, quit) */
|
||||
|
Loading…
Reference in New Issue
Block a user