20 |
|
|
21 |
|
#include "sysdeps.h" |
22 |
|
|
23 |
+ |
#include <stdlib.h> |
24 |
+ |
|
25 |
|
#include "mon.h" |
26 |
|
#include "mon_cmd.h" |
27 |
< |
#include "mon_ppc.h" |
28 |
< |
#include "mon_68k.h" |
29 |
< |
#include "mon_x86.h" |
30 |
< |
#include "mon_6502.h" |
31 |
< |
#include "mon_8080.h" |
30 |
< |
#include "version.h" |
27 |
> |
#include "mon_disass.h" |
28 |
> |
|
29 |
> |
#ifndef VERSION |
30 |
> |
#define VERSION "2" |
31 |
> |
#endif |
32 |
|
|
33 |
|
|
34 |
|
/* |
118 |
|
|
119 |
|
void version(void) |
120 |
|
{ |
121 |
< |
fprintf(monout, "mon V%d.%d\n", VERSION_MAJOR, VERSION_MINOR); |
121 |
> |
fprintf(monout, "mon V" VERSION "\n"); |
122 |
|
} |
123 |
|
|
124 |
|
|
171 |
|
} |
172 |
|
|
173 |
|
if (val > 0x7fffffff) { |
174 |
< |
fprintf(monout, "Hex unsigned: $%08lx\n" |
175 |
< |
"Hex signed : -$%08lx\n" |
176 |
< |
"Dec unsigned: %lu\n" |
177 |
< |
"Dec signed : %ld\n", val, -val, val, val); |
174 |
> |
fprintf(monout, "Hex unsigned: $%08x\n" |
175 |
> |
"Hex signed : -$%08x\n" |
176 |
> |
"Dec unsigned: %u\n" |
177 |
> |
"Dec signed : %d\n", val, -val, val, val); |
178 |
|
fprintf(monout, "Char : '%c%c%c%c'\n", char2print(val >> 24), char2print(val >> 16), char2print(val >> 8), char2print(val)); |
179 |
|
} else { |
180 |
< |
fprintf(monout, "Hex : $%08lx\n" |
181 |
< |
"Dec : %ld\n", val, val); |
180 |
> |
fprintf(monout, "Hex : $%08x\n" |
181 |
> |
"Dec : %d\n", val, val); |
182 |
|
fprintf(monout, "Char: '%c%c%c%c'\n", char2print(val >> 24), char2print(val >> 16), char2print(val >> 8), char2print(val)); |
183 |
|
} |
184 |
|
} |
222 |
|
return; |
223 |
|
|
224 |
|
while (adr <= end_adr && !mon_aborted()) { |
225 |
< |
fprintf(monout, "%08lx:", mon_use_real_mem ? adr: adr % mon_mem_size); |
225 |
> |
fprintf(monout, "%08x:", mon_use_real_mem ? adr: adr % mon_mem_size); |
226 |
|
for (int i=0; i<MEMDUMP_BPL; i++, adr++) { |
227 |
|
if (i % 4 == 0) |
228 |
< |
fprintf(monout, " %08lx", mon_read_word(adr)); |
228 |
> |
fprintf(monout, " %08x", mon_read_word(adr)); |
229 |
|
mem[i] = char2print(mon_read_byte(adr)); |
230 |
|
} |
231 |
|
fprintf(monout, " '%s'\n", mem); |
253 |
|
return; |
254 |
|
|
255 |
|
while (adr <= end_adr && !mon_aborted()) { |
256 |
< |
fprintf(monout, "%08lx:", mon_use_real_mem ? adr : adr % mon_mem_size); |
256 |
> |
fprintf(monout, "%08x:", mon_use_real_mem ? adr : adr % mon_mem_size); |
257 |
|
for (int i=0; i<ASCIIDUMP_BPL; i++, adr++) |
258 |
|
str[i] = char2print(mon_read_byte(adr)); |
259 |
|
fprintf(monout, " '%s'\n", str); |
264 |
|
|
265 |
|
|
266 |
|
/* |
267 |
+ |
* Binary dump |
268 |
+ |
* b [start [end]] |
269 |
+ |
*/ |
270 |
+ |
|
271 |
+ |
void binary_dump(void) |
272 |
+ |
{ |
273 |
+ |
uint32 adr, end_adr; |
274 |
+ |
uint8 str[9]; |
275 |
+ |
|
276 |
+ |
str[8] = 0; |
277 |
+ |
|
278 |
+ |
if (!range_args(&adr, &end_adr, 7)) // 8 lines unless end address specified |
279 |
+ |
return; |
280 |
+ |
|
281 |
+ |
while (adr <= end_adr && !mon_aborted()) { |
282 |
+ |
fprintf(monout, "%08x:", mon_use_real_mem ? adr : adr % mon_mem_size); |
283 |
+ |
uint8 b = mon_read_byte(adr); |
284 |
+ |
for (int m=0x80, i=0; i<8; m>>=1, i++) |
285 |
+ |
str[i] = (b & m) ? '*' : '.'; |
286 |
+ |
fprintf(monout, " '%s'\n", str); |
287 |
+ |
adr++; |
288 |
+ |
} |
289 |
+ |
|
290 |
+ |
mon_dot_address = adr; |
291 |
+ |
} |
292 |
+ |
|
293 |
+ |
|
294 |
+ |
/* |
295 |
|
* Disassemble |
296 |
|
* d [start [end]] |
297 |
|
* d65 [start [end]] |
319 |
|
case CPU_PPC: |
320 |
|
while (adr <= end_adr && !mon_aborted()) { |
321 |
|
uint32 w = mon_read_word(adr); |
322 |
< |
fprintf(monout, "%08lx: %08lx\t", mon_use_real_mem ? adr : adr % mon_mem_size, w); |
322 |
> |
fprintf(monout, "%08x: %08x\t", mon_use_real_mem ? adr : adr % mon_mem_size, w); |
323 |
|
disass_ppc(monout, mon_use_real_mem ? adr : adr % mon_mem_size, w); |
324 |
|
adr += 4; |
325 |
|
} |
330 |
|
uint8 op = mon_read_byte(adr); |
331 |
|
uint8 lo = mon_read_byte(adr + 1); |
332 |
|
uint8 hi = mon_read_byte(adr + 2); |
333 |
< |
fprintf(monout, "%08lx: ", mon_use_real_mem ? adr : adr % mon_mem_size); |
333 |
> |
fprintf(monout, "%08x: ", mon_use_real_mem ? adr : adr % mon_mem_size); |
334 |
|
adr += disass_6502(monout, mon_use_real_mem ? adr : adr % mon_mem_size, op, lo, hi); |
335 |
|
} |
336 |
|
break; |
337 |
|
|
338 |
|
case CPU_680x0: |
339 |
|
while (adr <= end_adr && !mon_aborted()) { |
340 |
< |
uint16 buf[8]; |
341 |
< |
buf[0] = mon_read_half(adr); |
313 |
< |
buf[1] = mon_read_half(adr + 2); |
314 |
< |
buf[2] = mon_read_half(adr + 4); |
315 |
< |
buf[3] = mon_read_half(adr + 6); |
316 |
< |
buf[4] = mon_read_half(adr + 8); |
317 |
< |
buf[5] = mon_read_half(adr + 10); |
318 |
< |
buf[6] = mon_read_half(adr + 12); |
319 |
< |
buf[7] = mon_read_half(adr + 14); |
320 |
< |
fprintf(monout, "%08lx: ", mon_use_real_mem ? adr : adr % mon_mem_size); |
321 |
< |
adr += disass_68k(monout, mon_use_real_mem ? adr : adr % mon_mem_size, buf); |
340 |
> |
fprintf(monout, "%08x: ", mon_use_real_mem ? adr : adr % mon_mem_size); |
341 |
> |
adr += disass_68k(monout, mon_use_real_mem ? adr : adr % mon_mem_size); |
342 |
|
} |
343 |
|
break; |
344 |
|
|
347 |
|
uint8 op = mon_read_byte(adr); |
348 |
|
uint8 lo = mon_read_byte(adr + 1); |
349 |
|
uint8 hi = mon_read_byte(adr + 2); |
350 |
< |
fprintf(monout, "%08lx: ", mon_use_real_mem ? adr : adr % mon_mem_size); |
350 |
> |
fprintf(monout, "%08x: ", mon_use_real_mem ? adr : adr % mon_mem_size); |
351 |
|
adr += disass_8080(monout, mon_use_real_mem ? adr : adr % mon_mem_size, op, lo, hi); |
352 |
|
} |
353 |
|
break; |
354 |
|
|
355 |
|
case CPU_80x86: |
356 |
|
while (adr <= end_adr && !mon_aborted()) { |
357 |
< |
uint8 buf[16]; |
358 |
< |
for (int i=0; i<16; i++) |
339 |
< |
buf[i] = mon_read_byte(adr + i); |
340 |
< |
fprintf(monout, "%08lx: ", mon_use_real_mem ? adr : adr % mon_mem_size); |
341 |
< |
adr += disass_x86(monout, mon_use_real_mem ? adr : adr % mon_mem_size, buf); |
357 |
> |
fprintf(monout, "%08x: ", mon_use_real_mem ? adr : adr % mon_mem_size); |
358 |
> |
adr += disass_x86(monout, mon_use_real_mem ? adr : adr % mon_mem_size); |
359 |
|
} |
360 |
|
break; |
361 |
|
} |
490 |
|
|
491 |
|
while (adr <= end_adr && !mon_aborted()) { |
492 |
|
if (mon_read_byte(adr) != mon_read_byte(dest)) { |
493 |
< |
fprintf(monout, "%08lx ", mon_use_real_mem ? adr : adr % mon_mem_size); |
493 |
> |
fprintf(monout, "%08x ", mon_use_real_mem ? adr : adr % mon_mem_size); |
494 |
|
num++; |
495 |
|
if (!(num & 7)) |
496 |
|
fputc('\n', monout); |
530 |
|
break; |
531 |
|
|
532 |
|
if (i == len) { |
533 |
< |
fprintf(monout, "%08lx ", mon_use_real_mem ? adr : adr % mon_mem_size); |
533 |
> |
fprintf(monout, "%08x ", mon_use_real_mem ? adr : adr % mon_mem_size); |
534 |
|
num++; |
535 |
|
if (num == 1) |
536 |
|
mon_dot_address = adr; |
582 |
|
mon_write_byte(adr++, fc); |
583 |
|
fclose(file); |
584 |
|
|
585 |
< |
fprintf(monerr, "%08lx bytes read from %08lx to %08lx\n", adr - start_adr, mon_use_real_mem ? start_adr : start_adr % mon_mem_size, mon_use_real_mem ? adr-1 : (adr-1) % mon_mem_size); |
585 |
> |
fprintf(monerr, "%08x bytes read from %08x to %08x\n", adr - start_adr, mon_use_real_mem ? start_adr : start_adr % mon_mem_size, mon_use_real_mem ? adr-1 : (adr-1) % mon_mem_size); |
586 |
|
mon_dot_address = adr; |
587 |
|
} |
588 |
|
} |
625 |
|
fputc(mon_read_byte(adr++), file); |
626 |
|
fclose(file); |
627 |
|
|
628 |
< |
fprintf(monerr, "%08lx bytes written from %08lx to %08lx\n", size, mon_use_real_mem ? start_adr : start_adr % mon_mem_size, mon_use_real_mem ? end_adr : end_adr % mon_mem_size); |
628 |
> |
fprintf(monerr, "%08x bytes written from %08x to %08x\n", size, mon_use_real_mem ? start_adr : start_adr % mon_mem_size, mon_use_real_mem ? end_adr : end_adr % mon_mem_size); |
629 |
|
} |
630 |
|
} |