More Debug Fun

More debugging options for the PET 2001 emulator.

A semi-abstract title image

There are times when your 6502 code doesn’t behave, where it steers off of its path into directions, never intended, when it runs away.
The new debugging traps for the PET 2001 emulator are meant for exactly those times. And they may be helpful for reverse engineering, as well.
Simply put, they are for those “How did we end up here?” moments. And the “Holy electron, Batman, what’s happening?” moments, as well.

In a nutshell, there are now

Let’s have a closer look (the debugger is available by its icon at to top-right corner of the browser window):

Debugging controls of the PET 2001 emulator with annotations for new options.
PET 2001 emulator: newly added debugger controls.

As before, new breakpoints, both simple ones and range brackets are set by the “New” button/link. This opens a new dialog, providing tabbed options, either for a simple breakpoint or a new range bracket. For breakpoints, it can be simply operated, just like with the previous prompt dialog: just type the address and hit ENTER.

Breakpoint prompt for the PET 2001 emulator.
The breakpoint dialog.

For range brackets, it’s a bit more complex, but you may tab your way through the individual controls.

Breakpoint prompt for the PET 2001 emulator, range bracket tab.
The breakpoint dialog, range bracket view.

In the breakpoints list, the type of a breakpoint will be indicated by an icon before the address or address range. The same icons are also displayed at the mini-disassembly for the current instruction, whenever a breakpoint triggers.

Breakpoint type indicator.
Breakpoint type indicators. (Checkboxes are for activating or deactivating individual breakpoints)

“Illegal” instructions come with a special indicator icon of their own:

CPU-readout and mini-disassembly with the breakpoint indicator.
The CPU-readout and mini-disassembly with the breakpoint indicator
(here, the trap for ”illegal” instructions triggered and halted the emulator.)

For the all-important question, “how did we end up here?”, click the button/link “Show CPU Log” beneath the trace window. This will show a dialog with a log of the last 1,000 instructions executed, ready for copy-and-paste. (The format is similar to the trace, but includes the status register, just like the CPU read-out, and flags bits are rendered as initials in upper and lower case for high and low, respectively, so that it may be easier to interpret them in a long list.)

PET 2001 emulator: CPU log.
The CPU log. (1,000 instructions is worth more than two 60Hz video frames on average.)

This is rather important for any range brackets triggering on exit: since a breakpoint or trap triggers on the very beginning of the execution of an instruction, PC will point to the new address already. To see how this happened, consult the CPU log. (More often than not an interrupt sequence may be involved.)

IMPORTANT: Mind that the option “ignore interrupts” (default on) also adheres to range brackets. If unchecked, these would trigger on any interrupt.

The CPU log can be brought up using the keyboard, as well: just hit SHIFT + ALT/OPTION + ENTER.
This works not only inside the debugger, but anytime, whenever the CPU is running and the emulator is scanning for input.

— Have fun! —