1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-06-11 05:29:33 +00:00

Show correct PC counter in scan

This commit is contained in:
Peter Evans 2018-03-01 21:37:10 -06:00
parent b239cac239
commit c5d1542937
4 changed files with 10 additions and 3 deletions

View File

@ -343,7 +343,13 @@ mos6502_dis_opcode(mos6502 *cpu, FILE *stream, int address)
void void
mos6502_dis_scan(mos6502 *cpu, FILE *stream, int pos, int end) mos6502_dis_scan(mos6502 *cpu, FILE *stream, int pos, int end)
{ {
vm_16bit pc;
pc = cpu->PC;
while (pos < end) { while (pos < end) {
cpu->PC = pos;
pos += mos6502_dis_opcode(cpu, stream, pos); pos += mos6502_dis_opcode(cpu, stream, pos);
} }
cpu->PC = pc;
} }

View File

@ -439,7 +439,7 @@ DEBUG_CMD(dblock)
} }
mos6502 *cpu = (mos6502 *)vm_di_get(VM_CPU); mos6502 *cpu = (mos6502 *)vm_di_get(VM_CPU);
FILE *stream = (FILE *)vm_di_get(VM_OUTPUT); FILE *stream = log_stream();
mos6502_dis_scan(cpu, stream, args->addr1, args->addr2); mos6502_dis_scan(cpu, stream, args->addr1, args->addr2);
} }

View File

@ -231,6 +231,6 @@ Test(mos6502_dis, scan)
// runtime operation) when you don't want it to, but as a standalone // runtime operation) when you don't want it to, but as a standalone
// disassembler, it feels less useful when PC isn't emulated. // disassembler, it feels less useful when PC isn't emulated.
assert_buf("0000:29 38 AND #$38\n" assert_buf("0000:29 38 AND #$38\n"
"0000:88 DEY \n" "0002:88 DEY \n"
"0000:6C 34 12 JMP ($1234)\n"); "0003:6C 34 12 JMP ($1234)\n");
} }

View File

@ -28,6 +28,7 @@ setup()
} }
vm_di_set(VM_OUTPUT, stream); vm_di_set(VM_OUTPUT, stream);
log_open(stream);
// Writing to stream will now write to buf // Writing to stream will now write to buf
setvbuf(stream, buf, _IOFBF, BUFSIZ); setvbuf(stream, buf, _IOFBF, BUFSIZ);