summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2020-05-03 23:28:42 -0700
committerMichael Pavone <pavone@retrodev.com>2020-05-03 23:28:42 -0700
commit77c5d5929206a78321b2d8bb74bbecf406b9b436 (patch)
tree32c67e27a789c95b3a7c017e8ab168cc9dc1c06f
parent11667366054d2c76cfe55713210e7bb0b1d2f22b (diff)
More correct implementation of byte printing in builtin debugger. Fix GDB debugger to use helper in backend.c for reading bytes
-rw-r--r--debug.c12
-rw-r--r--gdb_remote.c18
2 files changed, 11 insertions, 19 deletions
diff --git a/debug.c b/debug.c
index 12aa074..f04a477 100644
--- a/debug.c
+++ b/debug.c
@@ -95,6 +95,12 @@ void strip_nl(char * buf)
}
}
+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 @@ void debugger_print(m68k_context *context, char format_char, char *param, uint32
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 @@ void debugger_print(m68k_context *context, char format_char, char *param, uint32
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 --git a/gdb_remote.c b/gdb_remote.c
index cdc73a5..9dbfce4 100644
--- a/gdb_remote.c
+++ b/gdb_remote.c
@@ -132,22 +132,10 @@ void update_status(m68k_context * context, uint16_t value)
}
}
-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)