# HG changeset patch # User Michael Pavone # Date 1588573722 25200 # Node ID 3a46ff899fa6398285dc299e5377d10bbe4bf990 # Parent 9d35ce5012a65e48f3ef48b549679462c953978e More correct implementation of byte printing in builtin debugger. Fix GDB debugger to use helper in backend.c for reading bytes diff -r 9d35ce5012a6 -r 3a46ff899fa6 debug.c --- a/debug.c Sun May 03 23:24:03 2020 -0700 +++ b/debug.c Sun May 03 23:28:42 2020 -0700 @@ -95,6 +95,12 @@ } } +static uint8_t m68k_read_byte(uint32_t address, m68k_context *context) +{ + //TODO: share this implementation with GDB debugger + return read_byte(address, (void **)context->mem_pointers, &context->options->gen, context); +} + uint16_t m68k_read_word(uint32_t address, m68k_context *context) { return read_word(address, (void **)context->mem_pointers, &context->options->gen, context); @@ -159,8 +165,7 @@ if (after[0] == '.' && after[1] == 'l') { value = m68k_read_long(p_addr, context); } else if (after[0] == '.' && after[1] == 'b') { - value = m68k_read_word(p_addr, context); - value &= 0xFF; + value = m68k_read_byte(p_addr, context); } else { value = m68k_read_word(p_addr, context); } @@ -170,8 +175,7 @@ if (param[4] == '.' && param[5] == 'l') { value = m68k_read_long(p_addr, context); } else if (param[4] == '.' && param[5] == 'b') { - value = m68k_read_word(p_addr, context); - value &= 0xFF; + value = m68k_read_byte(p_addr, context); } else { value = m68k_read_word(p_addr, context); } diff -r 9d35ce5012a6 -r 3a46ff899fa6 gdb_remote.c --- a/gdb_remote.c Sun May 03 23:24:03 2020 -0700 +++ b/gdb_remote.c Sun May 03 23:28:42 2020 -0700 @@ -132,22 +132,10 @@ } } -uint8_t m68k_read_byte(m68k_context * context, uint32_t address) +static uint8_t m68k_read_byte(m68k_context *context, uint32_t address) { - - genesis_context *gen = context->system; - //TODO: Use generated read/write functions to support access to hardware that is not ROM or RAM - uint16_t * word = get_native_pointer(address & 0xFFFFFFFE, (void **)context->mem_pointers, &context->options->gen); - if (word) { - if (address & 1) { - return *word; - } - return *word >> 8; -} - if (address >= 0xA00000 && address < 0xA04000) { - return gen->zram[address & 0x1FFF]; - } - return 0; + //TODO: share this implementation with builtin debugger + return read_byte(address, (void **)context->mem_pointers, &context->options->gen, context); } void m68k_write_byte(m68k_context * context, uint32_t address, uint8_t value)