Mercurial > repos > blastem
comparison debug.c @ 1965:3a46ff899fa6
More correct implementation of byte printing in builtin debugger. Fix GDB debugger to use helper in backend.c for reading bytes
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 03 May 2020 23:28:42 -0700 |
parents | 495569c1dc61 |
children | a7b753e260a2 8ee7ecbf3f21 |
comparison
equal
deleted
inserted
replaced
1964:9d35ce5012a6 | 1965:3a46ff899fa6 |
---|---|
91 if (*buf == '\n') { | 91 if (*buf == '\n') { |
92 *buf = 0; | 92 *buf = 0; |
93 return; | 93 return; |
94 } | 94 } |
95 } | 95 } |
96 } | |
97 | |
98 static uint8_t m68k_read_byte(uint32_t address, m68k_context *context) | |
99 { | |
100 //TODO: share this implementation with GDB debugger | |
101 return read_byte(address, (void **)context->mem_pointers, &context->options->gen, context); | |
96 } | 102 } |
97 | 103 |
98 uint16_t m68k_read_word(uint32_t address, m68k_context *context) | 104 uint16_t m68k_read_word(uint32_t address, m68k_context *context) |
99 { | 105 { |
100 return read_word(address, (void **)context->mem_pointers, &context->options->gen, context); | 106 return read_word(address, (void **)context->mem_pointers, &context->options->gen, context); |
157 char *after; | 163 char *after; |
158 uint32_t p_addr = strtol(param+(param[0] == '0' ? 2 : 1), &after, 16); | 164 uint32_t p_addr = strtol(param+(param[0] == '0' ? 2 : 1), &after, 16); |
159 if (after[0] == '.' && after[1] == 'l') { | 165 if (after[0] == '.' && after[1] == 'l') { |
160 value = m68k_read_long(p_addr, context); | 166 value = m68k_read_long(p_addr, context); |
161 } else if (after[0] == '.' && after[1] == 'b') { | 167 } else if (after[0] == '.' && after[1] == 'b') { |
162 value = m68k_read_word(p_addr, context); | 168 value = m68k_read_byte(p_addr, context); |
163 value &= 0xFF; | |
164 } else { | 169 } else { |
165 value = m68k_read_word(p_addr, context); | 170 value = m68k_read_word(p_addr, context); |
166 } | 171 } |
167 } else if(param[0] == '(' && (param[1] == 'a' || param[1] == 'd') && param[2] >= '0' && param[2] <= '7' && param[3] == ')') { | 172 } else if(param[0] == '(' && (param[1] == 'a' || param[1] == 'd') && param[2] >= '0' && param[2] <= '7' && param[3] == ')') { |
168 uint8_t reg = param[2] - '0'; | 173 uint8_t reg = param[2] - '0'; |
169 uint32_t p_addr = param[1] == 'a' ? context->aregs[reg] : context->dregs[reg]; | 174 uint32_t p_addr = param[1] == 'a' ? context->aregs[reg] : context->dregs[reg]; |
170 if (param[4] == '.' && param[5] == 'l') { | 175 if (param[4] == '.' && param[5] == 'l') { |
171 value = m68k_read_long(p_addr, context); | 176 value = m68k_read_long(p_addr, context); |
172 } else if (param[4] == '.' && param[5] == 'b') { | 177 } else if (param[4] == '.' && param[5] == 'b') { |
173 value = m68k_read_word(p_addr, context); | 178 value = m68k_read_byte(p_addr, context); |
174 value &= 0xFF; | |
175 } else { | 179 } else { |
176 value = m68k_read_word(p_addr, context); | 180 value = m68k_read_word(p_addr, context); |
177 } | 181 } |
178 } else { | 182 } else { |
179 fprintf(stderr, "Unrecognized parameter to p: %s\n", param); | 183 fprintf(stderr, "Unrecognized parameter to p: %s\n", param); |