A debugger for the Apple II25 Feb 2018
Lately, I have been testing erc with different ROMs to see what it’s doing—mostly, to see what it’s doing wrong. erc is able to disassemble machine code, and following along with that has been very helpful, but I decided what I really wanted was a debugger: something to stop execution, look at the machine state, and make changes to it.
So, I wrote a debugger:
FA62:D8 CLD erc> h break b <addr> Add breakpoint at <addr> help h Print out this list of commands jump j <addr> Jump to <addr> for next execution printaddr pa <addr> Print the value at <addr> printstate ps Print the machine and CPU state quit q Quit the emulator resume r Resume execution step s Execute just one opcode unbreak u <addr> Remove breakpoint at <addr> writeaddr wa <addr> <byte> Write <byte> at <addr> writestate ws <reg> <byte> Write <byte> into <reg> FA62:D8 CLD erc> s FA63:20 84 FE JSR $FE84 erc> s FE84:A0 FF LDY #$FF erc> ps CPU: A:00 X:00 Y:00 P:c7 S:fd PC:fe84 MACH: BS:00 CM:03 DM:04 MM:40 STROBE:00 FE84:A0 FF LDY #$FF erc> ws x d8 FE84:A0 FF LDY #$FF erc> ps CPU: A:00 X:d8 Y:00 P:c7 S:fd PC:fe84 MACH: BS:00 CM:03 DM:04 MM:40 STROBE:00 FE84:A0 FF LDY #$FF
The debugger resembles gdb in spirit, if not in practice. I’m hoping to add a backtrace command so you can see what the previous JMPs and JSRs (jumps-to-subroutine) were; it’s not quite straightforward, as software can—and does, quite often!—use the stack for more than just managing function calls.
Finally, hello! This is the first post of the erc blog. I figured I’d put something together, if only to let people know how it’s going. (It’s going!)