Debugger

Writing a Z80 debugger that runs in software alongside the code you want to debug is a bit like trying to catch a lion: the lion really has to want to be caught. Whether the Astrum debugger is useful to you will really depend on what your code does and which bits you want to debug. It has been used to successfully debug quite a complicated piece of code and it made stepping and analysing the code quite easy. Like the lion, if you and your code want to use the debugger you can! When the assembler has successfully completed you have a binary file. The assembler keeps the symbol tables in memory and the debugger can use these to help you debug your code.

When your code is to be debugged, Astrum will load a version of the debugger that lives below your codes ORG. Hopefully that will mean the debugger will be out of the way. It also pages out the editor and source code, leaving only the portion of Astrum between 26000 and 32767 visible. This portion is needed to return from the debugger.

You can run the debugger separately. Load the appropriate debugger, they are marked with the load address. For example if you need the one that loads at $c000 then do:

    LOAD "debugc000" code $c000
    rand usr $c000

Commands

In the below commands xxxx denotes a 16-bit number. This can be a hex number, a decimal number (if preceded by a =) or a symbol from your assembler. It can also take simple expressions in involving +. So BUFFER+10 is valid for 16 bytes past BUFFER. nn denotes an 8-bit value.

D xxxx nnDisassemble nn instructions from xxxx. nn can be omitted and will default to 8. xxxx can be omitted and will default to the current instruction.
P xxxxShow the value of xxxx
I nnDoes an IN on Spectrum Next register nn
M xxxx nnShow the contents of nn bytes of memory starting at xxxx. nn can be omitted and will default to 16. xxxx can be omitted and it will default to the value in HL.
E xxxx nn Set the contents of memory location xxxx to nn. This will show the memory as a confirmation
EW xxxx nnnn Set the contents of memory location xxxx and xxxx+1 to the 16-bit word nnnn. This will show the memory as a confirmation
ER rr nnnn Set the contents of register rr to the 16-bit word nnnn. This will show the registers as a confirmation
RShow registers
UShow current 8kB page mappings.
SStep (i.e. execute) the current instruction.
OStep over (i.e. execute) the current instruction. If the instruction is a call then the whole routine will be executed
G xxxxGet to xxxx. This runs your code until the program counter gets to xxxx.
C Continue. Runs your code from the current point. If you try to continue at a location that has a breakpoint then nothing will happen - you should Step once then continue.
B xxxx Sets a breakpoint at location xxxx. If your code is run with Continue and the instruction at xxxx is executed then the debugger should get back control. You can set up to eight breakpoints.
BC xxxx Clears a breakpoint at xxxx.
BL List breakpoints
BXClear all breakpoints
Z xxxxSet the program counter to xxxx