# HG changeset patch # User Michael Pavone # Date 1586826862 25200 # Node ID 23394a8905082280378acec142547a04cc2d5b88 # Parent 4a811fd1fb6fa22c1d6122579fd2e8b123a6bfbd Added implementation of printing PC in 68K debugger diff -r 4a811fd1fb6f -r 23394a890508 debug.c --- a/debug.c Fri Apr 10 23:01:13 2020 +1000 +++ b/debug.c Mon Apr 13 18:14:22 2020 -0700 @@ -105,7 +105,7 @@ return m68k_read_word(address, context) << 16 | m68k_read_word(address + 2, context); } -void debugger_print(m68k_context *context, char format_char, char *param) +void debugger_print(m68k_context *context, char format_char, char *param, uint32_t address) { uint32_t value; char format[8]; @@ -152,7 +152,7 @@ genesis_context *gen = context->system; value = gen->vdp->frame; } else if (param[0] == 'p' && param[1] == 'c') { - value = 0; //TODO PC value here; + value = address; } else if ((param[0] == '0' && param[1] == 'x') || param[0] == '$') { char *after; uint32_t p_addr = strtol(param+(param[0] == '0' ? 2 : 1), &after, 16); @@ -693,7 +693,7 @@ fputs("display command requires a parameter\n", stderr); break; } - debugger_print(context, format_char, param); + debugger_print(context, format_char, param, address); add_display(&displays, &disp_index, format_char, param); } else { param = find_param(input_buf); @@ -724,12 +724,13 @@ } } param = find_param(input_buf); - if (!param) { + if (param) { + debugger_print(context, format_char, param, address); + } else { m68k_disasm(&inst, input_buf); printf("%X: %s\n", address, input_buf); - break; } - debugger_print(context, format_char, param); + break; case 'n': if (inst.op == M68K_RTS) { @@ -1054,7 +1055,7 @@ remove_breakpoint(context, address); } for (disp_def * cur = displays; cur; cur = cur->next) { - debugger_print(context, cur->format_char, cur->param); + debugger_print(context, cur->format_char, cur->param, address); } m68k_disasm(&inst, input_buf); printf("%X: %s\n", address, input_buf);