|
|
1.1 root 1: /*
2: * UAE - The Unusable Amiga Emulator
3: *
4: * debugger v0.0
5: *
6: * (c) 1995 Bernd Schmidt
7: *
8: */
9:
10: #include <ctype.h>
11: #include <iostream.h>
12: #include <iomanip.h>
13:
14: #include "amiga.h"
15: #include "memory.h"
16: #include "cpu.h"
17: #include "custom.h"
18: #include "cia.h"
19:
20: void ignore_ws(char *&c)
21: {
22: while (isspace(*c)) c++;
23: }
24:
25: ULONG readhex(char *&c)
26: {
27: ULONG val = 0;
28: char nc;
29:
30: ignore_ws(c);
31:
32: while (isxdigit(nc = *c++)){
33: val *= 16;
34: nc = toupper(nc);
35: if (isdigit(nc)) {
36: val += nc - '0';
37: } else {
38: val += nc - 'A' + 10;
39: }
40: }
41: return val;
42: }
43:
44: char getchar(char *&c)
45: {
46: ignore_ws(c);
47: return *c++;
48: }
49:
50: bool more_params(char *&c)
51: {
52: ignore_ws(c);
53: return (*c) != 0;
54: }
55:
56: void dumpmem(CPTR addr,CPTR &nxmem,int lines)
57: {
58: for (;lines--;){
59: cout << hex << setfill('0') << setw(8) << addr << " ";
60: for(int i=0; i< 16; i++) {
61: cout << setw(4) << mem.get_word(addr) << " "; addr += 2;
62: }
63: cout << "\n";
64: }
65: nxmem = addr;
66: }
67:
68: void debug()
69: {
70: char input[80],c;
71: CPTR nextpc,nxdis,nxmem;
72:
73: cout << "debugging...\n";
74: MC68000_dumpstate(nextpc);
75: nxdis = nextpc; nxmem = 0;
76: for(;;){
77: char cmd,*inptr;
78: cout << ">";
79: cin.get(input,80,'\n');
80: cin.get(c);
81: inptr = input;
82: cmd = getchar(inptr);
83: switch(cmd){
84: case 'q':
85: return;
86: case 'c':
87: dumpcia(); dumpcustom(); break;
88: case 'r':
89: MC68000_dumpstate(nextpc); break;
90: case 'd':
91: {
92: ULONG daddr;
93: int count;
94:
95: if (more_params(inptr)) daddr = readhex(inptr); else daddr = nxdis;
96: if (more_params(inptr)) count = readhex(inptr); else count = 10;
97: MC68000_disasm(daddr,nxdis,count);
98: }
99: break;
100: case 't':
101: MC68000_step(); MC68000_dumpstate(nextpc); break;
102: case 'z':
103: MC68000_skip(nextpc); MC68000_dumpstate(nextpc); nxdis = nextpc; break;
104: case 'f':
105: MC68000_skip(readhex(inptr)); MC68000_dumpstate(nextpc); break;
106: case 'm':
107: {
108: ULONG maddr; int lines;
109: if (more_params(inptr)) maddr = readhex(inptr); else maddr = nxmem;
110: if (more_params(inptr)) lines = readhex(inptr); else lines = 16;
111: dumpmem(maddr,nxmem,lines);
112: }
113: break;
114: }
115: }
116: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.