From d08a950ccee11282ff2b7fb38ae6e7ee7df99b11 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Mon, 13 Apr 2020 18:14:22 -0700 Subject: Added implementation of printing PC in 68K debugger --- debug.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'debug.c') diff --git a/debug.c b/debug.c index d49a924..f58cbc1 100644 --- a/debug.c +++ b/debug.c @@ -105,7 +105,7 @@ uint32_t m68k_read_long(uint32_t address, m68k_context *context) 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 @@ void debugger_print(m68k_context *context, char format_char, char *param) 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 @@ int run_debugger_command(m68k_context *context, uint32_t address, char *input_bu 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 @@ int run_debugger_command(m68k_context *context, uint32_t address, char *input_bu } } 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 @@ void debugger(m68k_context * context, uint32_t address) 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); -- cgit v1.2.3