23 |
|
#include "readcpu.h" |
24 |
|
#include "newcpu.h" |
25 |
|
|
26 |
+ |
#if ENABLE_MON |
27 |
+ |
#include "mon.h" |
28 |
+ |
#include "mon_disass.h" |
29 |
+ |
#endif |
30 |
+ |
|
31 |
|
int quit_program = 0; |
32 |
|
int debugging = 0; |
33 |
|
struct flag_struct regflags; |
52 |
|
|
53 |
|
cpuop_func *cpufunctbl[65536]; |
54 |
|
|
55 |
+ |
#define FLIGHT_RECORDER 0 |
56 |
+ |
|
57 |
+ |
#if FLIGHT_RECORDER |
58 |
+ |
struct rec_step { |
59 |
+ |
uae_u32 d[8]; |
60 |
+ |
uae_u32 a[8]; |
61 |
+ |
uae_u32 pc; |
62 |
+ |
}; |
63 |
+ |
|
64 |
+ |
const int LOG_SIZE = 8192; |
65 |
+ |
static rec_step log[LOG_SIZE]; |
66 |
+ |
static int log_ptr = -1; // First time initialization |
67 |
+ |
|
68 |
+ |
static const char *log_filename(void) |
69 |
+ |
{ |
70 |
+ |
const char *name = getenv("M68K_LOG_FILE"); |
71 |
+ |
return name ? name : "log.68k"; |
72 |
+ |
} |
73 |
+ |
|
74 |
+ |
static void record_step(uaecptr pc) |
75 |
+ |
{ |
76 |
+ |
for (int i = 0; i < 8; i++) { |
77 |
+ |
log[log_ptr].d[i] = m68k_dreg(regs, i); |
78 |
+ |
log[log_ptr].a[i] = m68k_areg(regs, i); |
79 |
+ |
} |
80 |
+ |
log[log_ptr].pc = pc; |
81 |
+ |
log_ptr = (log_ptr + 1) % LOG_SIZE; |
82 |
+ |
} |
83 |
+ |
|
84 |
+ |
static void dump_log(void) |
85 |
+ |
{ |
86 |
+ |
FILE *f = fopen(log_filename(), "w"); |
87 |
+ |
if (f == NULL) |
88 |
+ |
return; |
89 |
+ |
for (int i = 0; i < LOG_SIZE; i++) { |
90 |
+ |
int j = (i + log_ptr) % LOG_SIZE; |
91 |
+ |
fprintf(f, "pc %08x\n", log[j].pc); |
92 |
+ |
fprintf(f, "d0 %08x d1 %08x d2 %08x d3 %08x\n", log[j].d[0], log[j].d[1], log[j].d[2], log[j].d[3]); |
93 |
+ |
fprintf(f, "d4 %08x d5 %08x d6 %08x d7 %08x\n", log[j].d[4], log[j].d[5], log[j].d[6], log[j].d[7]); |
94 |
+ |
fprintf(f, "a0 %08x a1 %08x a2 %08x a3 %08x\n", log[j].a[0], log[j].a[1], log[j].a[2], log[j].a[3]); |
95 |
+ |
fprintf(f, "a4 %08x a5 %08x a6 %08x a7 %08x\n", log[j].a[4], log[j].a[5], log[j].a[6], log[j].a[7]); |
96 |
+ |
#if ENABLE_MON |
97 |
+ |
disass_68k(f, log[j].pc); |
98 |
+ |
#endif |
99 |
+ |
} |
100 |
+ |
} |
101 |
+ |
#endif |
102 |
+ |
|
103 |
|
#define COUNT_INSTRS 0 |
104 |
|
|
105 |
|
#if COUNT_INSTRS |
1128 |
|
/* gb-- moved into {fpp,fpu_x86}.cpp::fpu_init() |
1129 |
|
regs.fpcr = regs.fpsr = regs.fpiar = 0; */ |
1130 |
|
fpu_reset(); |
1131 |
+ |
|
1132 |
+ |
#if FLIGHT_RECORDER |
1133 |
+ |
#if ENABLE_MON |
1134 |
+ |
if (log_ptr == -1) { |
1135 |
+ |
// Install "log" command in mon |
1136 |
+ |
mon_add_command("log", dump_log, "log Dump m68k emulation log\n"); |
1137 |
+ |
} |
1138 |
+ |
#endif |
1139 |
+ |
log_ptr = 0; |
1140 |
+ |
memset(log, 0, sizeof(log)); |
1141 |
+ |
#endif |
1142 |
|
} |
1143 |
|
|
1144 |
|
void REGPARAM2 op_illg (uae_u32 opcode) |
1285 |
|
{ |
1286 |
|
for (;;) { |
1287 |
|
uae_u32 opcode = GET_OPCODE; |
1288 |
+ |
#if FLIGHT_RECORDER |
1289 |
+ |
record_step(m68k_getpc()); |
1290 |
+ |
#endif |
1291 |
|
(*cpufunctbl[opcode])(opcode); |
1292 |
|
if (regs.spcflags) { |
1293 |
|
if (do_specialties()) |