mirror of
https://github.com/RyuKojiro/apple1.git
synced 2024-06-08 13:29:28 +00:00
Dump asm history to a file for debugging
git-svn-id: svn+ssh://svn.phoenixbox.net/svn/apple1/trunk@23 64f78de7-aa59-e511-a0e8-0002a5492df0
This commit is contained in:
parent
b9de338cbf
commit
f2354561a8
|
@ -46,30 +46,30 @@ uint8_t romMirrorCallback(struct _v6502_memory *memory, uint16_t offset, int tra
|
||||||
return memory->bytes[offset % ROM_SIZE];
|
return memory->bytes[offset % ROM_SIZE];
|
||||||
}
|
}
|
||||||
|
|
||||||
static int printSingleInstruction(v6502_cpu *cpu, uint16_t address) {
|
static int printSingleInstruction(FILE *output, v6502_cpu *cpu, uint16_t address) {
|
||||||
char instruction[MAX_INSTRUCTION_LEN];
|
char instruction[MAX_INSTRUCTION_LEN];
|
||||||
int instructionLength;
|
int instructionLength;
|
||||||
dis6502_stringForInstruction(instruction, MAX_INSTRUCTION_LEN, cpu->memory->bytes[address], cpu->memory->bytes[address + 2], cpu->memory->bytes[address + 1]);
|
dis6502_stringForInstruction(instruction, MAX_INSTRUCTION_LEN, cpu->memory->bytes[address], cpu->memory->bytes[address + 2], cpu->memory->bytes[address + 1]);
|
||||||
instructionLength = v6502_instructionLengthForOpcode(cpu->memory->bytes[address]);
|
instructionLength = v6502_instructionLengthForOpcode(cpu->memory->bytes[address]);
|
||||||
|
|
||||||
printf("0x%04x: ", address);
|
fprintf(output, "0x%04x: ", address);
|
||||||
|
|
||||||
switch (instructionLength) {
|
switch (instructionLength) {
|
||||||
case 1: {
|
case 1: {
|
||||||
printf("%02x ", cpu->memory->bytes[address]);
|
fprintf(output, "%02x ", cpu->memory->bytes[address]);
|
||||||
} break;
|
} break;
|
||||||
case 2: {
|
case 2: {
|
||||||
printf("%02x %02x ", cpu->memory->bytes[address], cpu->memory->bytes[address + 1]);
|
fprintf(output, "%02x %02x ", cpu->memory->bytes[address], cpu->memory->bytes[address + 1]);
|
||||||
} break;
|
} break;
|
||||||
case 3: {
|
case 3: {
|
||||||
printf("%02x %02x %02x", cpu->memory->bytes[address], cpu->memory->bytes[address + 1], cpu->memory->bytes[address + 2]);
|
fprintf(output, "%02x %02x %02x", cpu->memory->bytes[address], cpu->memory->bytes[address + 1], cpu->memory->bytes[address + 2]);
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
printf(" ");
|
fprintf(output, " ");
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" - %s\n", instruction);
|
fprintf(output, " - %s\r\n", instruction);
|
||||||
|
|
||||||
return instructionLength;
|
return instructionLength;
|
||||||
}
|
}
|
||||||
|
@ -97,10 +97,12 @@ int main(int argc, const char * argv[])
|
||||||
v6502_reset(cpu);
|
v6502_reset(cpu);
|
||||||
|
|
||||||
// printSingleInstruction(cpu, cpu->pc);
|
// printSingleInstruction(cpu, cpu->pc);
|
||||||
|
FILE *asmfile = fopen("runtime.s", "w");
|
||||||
while (!faulted) {
|
while (!faulted) {
|
||||||
v6502_step(cpu);
|
v6502_step(cpu);
|
||||||
// printSingleInstruction(cpu, cpu->pc);
|
printSingleInstruction(asmfile, cpu, cpu->pc);
|
||||||
}
|
}
|
||||||
|
fclose(asmfile);
|
||||||
|
|
||||||
pia_destroy(pia);
|
pia_destroy(pia);
|
||||||
v6502_destroyMemory(cpu->memory);
|
v6502_destroyMemory(cpu->memory);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user