diff --git a/include/vm_debug.h b/include/vm_debug.h index 485e081..10c54d6 100644 --- a/include/vm_debug.h +++ b/include/vm_debug.h @@ -72,5 +72,6 @@ extern DEBUG_CMD(jump); extern DEBUG_CMD(printaddr); extern DEBUG_CMD(printstate); extern DEBUG_CMD(resume); +extern DEBUG_CMD(writeaddr); #endif diff --git a/src/vm_debug.c b/src/vm_debug.c index a5368b4..d134f2d 100644 --- a/src/vm_debug.c +++ b/src/vm_debug.c @@ -192,3 +192,9 @@ DEBUG_CMD(jump) mos6502 *cpu = (mos6502 *)vm_di_get(VM_CPU); cpu->PC = args->addr1; } + +DEBUG_CMD(writeaddr) +{ + mos6502 *cpu = (mos6502 *)vm_di_get(VM_CPU); + mos6502_set(cpu, args->addr1, args->addr2); +} diff --git a/tests/vm_debug.c b/tests/vm_debug.c index 3628816..5eb1fc4 100644 --- a/tests/vm_debug.c +++ b/tests/vm_debug.c @@ -109,9 +109,18 @@ Test(vm_debug, cmd_printaddr) cr_assert_str_eq(buf, "$7F\n"); } -Test(vm_debug, jump) +Test(vm_debug, cmd_jump) { args.addr1 = 123; vm_debug_cmd_jump(&args); cr_assert_eq(mach->cpu->PC, 123); } + +Test(vm_debug, cmd_writeaddr) +{ + args.addr1 = 123; + args.addr2 = 0xf5; + + vm_debug_cmd_writeaddr(&args); + cr_assert_eq(mos6502_get(mach->cpu, args.addr1), args.addr2); +}