mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-22 00:32:44 +00:00
use cpu's instruction logging facilities
This commit is contained in:
parent
384b968a15
commit
49711b79d5
@ -304,6 +304,45 @@ void InitializeMPW(int argc, char **argv)
|
||||
WriteLong(Memory, 0x0a06, 0xffffffff);
|
||||
}
|
||||
|
||||
|
||||
void InstructionLogger()
|
||||
{
|
||||
|
||||
static char strings[4][256];
|
||||
for (unsigned j = 0; j < 4; ++j) strings[j][0] = 0;
|
||||
|
||||
uint32_t pc = cpuGetPC();
|
||||
//uint16_t opcode = ReadWord(Memory, pc);
|
||||
|
||||
#if 0
|
||||
if ((opcode & 0xf000) == 0xa000)
|
||||
{
|
||||
fprintf(stderr, "tool %04x\n", opcode);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
fprintf(stderr, "D0 D1 D2 D3 D4 D5 D6 D7 A0 A1 A2 A3 A4 A5 A6 A7\n");
|
||||
fprintf(stderr, "%08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
cpuGetDReg(0), cpuGetDReg(1), cpuGetDReg(2), cpuGetDReg(3),
|
||||
cpuGetDReg(4), cpuGetDReg(5), cpuGetDReg(6), cpuGetDReg(7),
|
||||
cpuGetAReg(0), cpuGetAReg(1), cpuGetAReg(2), cpuGetAReg(3),
|
||||
cpuGetAReg(4), cpuGetAReg(5), cpuGetAReg(6), cpuGetAReg(7)
|
||||
);
|
||||
#endif
|
||||
// todo - check for Axxx, recognize as a toolcall.
|
||||
// move this to the cpuLogging facility?
|
||||
cpuDisOpcode(pc, strings[0], strings[1], strings[2], strings[3]);
|
||||
|
||||
// address, data, instruction, operand
|
||||
fprintf(stderr, "%s %-10s %-40s ; %s\n", strings[0], strings[2], strings[3], strings[1]);
|
||||
|
||||
// todo -- trace registers (only print changed registers?)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void help()
|
||||
{
|
||||
|
||||
@ -470,41 +509,18 @@ int main(int argc, char **argv)
|
||||
|
||||
cpuSetALineExceptionFunc(ToolBox::dispatch);
|
||||
memorySetMemory(Memory, MemorySize);
|
||||
memorySetGlobalLog(0x10000);
|
||||
|
||||
MM::Init(Memory, MemorySize, HighWater);
|
||||
|
||||
for (unsigned i = 0; i < 10000; ++i)
|
||||
if (Flags.traceCPU)
|
||||
{
|
||||
if (Flags.traceCPU)
|
||||
{
|
||||
static char strings[4][256];
|
||||
for (unsigned j = 0; j < 4; ++j) strings[j][0] = 0;
|
||||
cpuSetInstructionLoggingFunc(InstructionLogger);
|
||||
}
|
||||
|
||||
uint32_t pc = cpuGetPC();
|
||||
uint16_t opcode = ReadWord(Memory, pc);
|
||||
for (unsigned i = 0; i < 9200; ++i)
|
||||
{
|
||||
|
||||
if ((opcode & 0xf000) == 0xa000)
|
||||
{
|
||||
fprintf(stderr, "tool %04x\n", opcode);
|
||||
}
|
||||
|
||||
#if 0
|
||||
fprintf(stderr, "D0 D1 D2 D3 D4 D5 D6 D7 A0 A1 A2 A3 A4 A5 A6 A7\n");
|
||||
fprintf(stderr, "%08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
cpuGetDReg(0), cpuGetDReg(1), cpuGetDReg(2), cpuGetDReg(3),
|
||||
cpuGetDReg(4), cpuGetDReg(5), cpuGetDReg(6), cpuGetDReg(7),
|
||||
cpuGetAReg(0), cpuGetAReg(1), cpuGetAReg(2), cpuGetAReg(3),
|
||||
cpuGetAReg(4), cpuGetAReg(5), cpuGetAReg(6), cpuGetAReg(7)
|
||||
);
|
||||
#endif
|
||||
// todo - check for Axxx, recognize as a toolcall.
|
||||
// move this to the cpuLogging facility?
|
||||
cpuDisOpcode(pc, strings[0], strings[1], strings[2], strings[3]);
|
||||
|
||||
// address, data, instruction, operand
|
||||
fprintf(stderr, "%s %-10s %-40s ; %s\n", strings[0], strings[2], strings[3], strings[1]);
|
||||
|
||||
// todo -- trace registers (only print changed registers?)
|
||||
}
|
||||
cpuExecuteInstruction();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user