1 |
|
/* |
2 |
|
* mon_cmd.cpp - mon standard commands |
3 |
|
* |
4 |
< |
* (C) 1997-1999 Christian Bauer |
4 |
> |
* mon (C) 1997-1999 Christian Bauer, Marc Hellwig |
5 |
> |
* |
6 |
> |
* This program is free software; you can redistribute it and/or modify |
7 |
> |
* it under the terms of the GNU General Public License as published by |
8 |
> |
* the Free Software Foundation; either version 2 of the License, or |
9 |
> |
* (at your option) any later version. |
10 |
> |
* |
11 |
> |
* This program is distributed in the hope that it will be useful, |
12 |
> |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
> |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
> |
* GNU General Public License for more details. |
15 |
> |
* |
16 |
> |
* You should have received a copy of the GNU General Public License |
17 |
> |
* along with this program; if not, write to the Free Software |
18 |
> |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
|
*/ |
20 |
|
|
21 |
< |
#include <stdio.h> |
22 |
< |
#include <string.h> |
23 |
< |
#include <unistd.h> |
21 |
> |
#include "sysdeps.h" |
22 |
> |
|
23 |
> |
#include <stdlib.h> |
24 |
|
|
25 |
|
#include "mon.h" |
26 |
|
#include "mon_cmd.h" |
118 |
|
|
119 |
|
void version(void) |
120 |
|
{ |
121 |
< |
fprintf(monout, "mon V%d.%d\n", MON_VERSION, MON_REVISION); |
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; |
346 |
|
buf[5] = mon_read_half(adr + 10); |
347 |
|
buf[6] = mon_read_half(adr + 12); |
348 |
|
buf[7] = mon_read_half(adr + 14); |
349 |
< |
fprintf(monout, "%08lx: ", mon_use_real_mem ? adr : adr % mon_mem_size); |
349 |
> |
fprintf(monout, "%08x: ", mon_use_real_mem ? adr : adr % mon_mem_size); |
350 |
|
adr += disass_68k(monout, mon_use_real_mem ? adr : adr % mon_mem_size, buf); |
351 |
|
} |
352 |
|
break; |
356 |
|
uint8 op = mon_read_byte(adr); |
357 |
|
uint8 lo = mon_read_byte(adr + 1); |
358 |
|
uint8 hi = mon_read_byte(adr + 2); |
359 |
< |
fprintf(monout, "%08lx: ", mon_use_real_mem ? adr : adr % mon_mem_size); |
359 |
> |
fprintf(monout, "%08x: ", mon_use_real_mem ? adr : adr % mon_mem_size); |
360 |
|
adr += disass_8080(monout, mon_use_real_mem ? adr : adr % mon_mem_size, op, lo, hi); |
361 |
|
} |
362 |
|
break; |
366 |
|
uint8 buf[16]; |
367 |
|
for (int i=0; i<16; i++) |
368 |
|
buf[i] = mon_read_byte(adr + i); |
369 |
< |
fprintf(monout, "%08lx: ", mon_use_real_mem ? adr : adr % mon_mem_size); |
369 |
> |
fprintf(monout, "%08x: ", mon_use_real_mem ? adr : adr % mon_mem_size); |
370 |
|
adr += disass_x86(monout, mon_use_real_mem ? adr : adr % mon_mem_size, buf); |
371 |
|
} |
372 |
|
break; |
502 |
|
|
503 |
|
while (adr <= end_adr && !mon_aborted()) { |
504 |
|
if (mon_read_byte(adr) != mon_read_byte(dest)) { |
505 |
< |
fprintf(monout, "%08lx ", mon_use_real_mem ? adr : adr % mon_mem_size); |
505 |
> |
fprintf(monout, "%08x ", mon_use_real_mem ? adr : adr % mon_mem_size); |
506 |
|
num++; |
507 |
|
if (!(num & 7)) |
508 |
|
fputc('\n', monout); |
542 |
|
break; |
543 |
|
|
544 |
|
if (i == len) { |
545 |
< |
fprintf(monout, "%08lx ", mon_use_real_mem ? adr : adr % mon_mem_size); |
545 |
> |
fprintf(monout, "%08x ", mon_use_real_mem ? adr : adr % mon_mem_size); |
546 |
|
num++; |
547 |
|
if (num == 1) |
548 |
|
mon_dot_address = adr; |
594 |
|
mon_write_byte(adr++, fc); |
595 |
|
fclose(file); |
596 |
|
|
597 |
< |
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); |
597 |
> |
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); |
598 |
|
mon_dot_address = adr; |
599 |
|
} |
600 |
|
} |
637 |
|
fputc(mon_read_byte(adr++), file); |
638 |
|
fclose(file); |
639 |
|
|
640 |
< |
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); |
640 |
> |
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); |
641 |
|
} |
642 |
|
} |