Debugging
The KIM-1 monitor has several debugging features that require to fill the interrupt vectors at 17FA, and 17FE. Enter 1C00 here.
17FA NMIT for Single stepping
17FE IRQV for BRK handling
You can single step your program, examining and altering memory and registers before the next instruction is executed.
Or place breakpoints in your program at interesting points. And use a combination of both.
The debugging uses these zeropage locations. Stored by SAVE ($1C00) and loaded by G or GO via GOEXEC.
0069 00EF .ORG $00EF 0070 00EF ; MPU REG. SAVX AREA IN PAGE 0 0071 00EF ; 0072 00EF PCL .BLOCK 1 ; PROGRAM CNT LOW 0073 00F0 PCH .BLOCK 1 ; PROGRAM CNT HI 0074 00F1 PREG .BLOCK 1 ; CURRENT STATUS REG. 0075 00F2 SPUSER .BLOCK 1 ; CURRENT STACK POINT 0076 00F3 ACC .BLOCK 1 ; ACCUMULATOR 0077 00F4 YREG .BLOCK 1 ; Y INDEX 0078 00F5 XREG .BLOCK 1 ; X INDEX
The SST slide switch activates single step activation
After a G one instruction is executed and the monitor is active again
Now you can inspect/change memory and the saved registers in zeropage, and continue after the last executed instruction.
Using a BRK as breakpoint, temporary replacing the instruction at this location manually.
A BRK instruction lets the CPU execute the IRQ vector. When this is 1C00, SAVE routine is executed, saving all registers in EF and on.
Example of a BRK breakpoint
KIM 00F8 00 200 0200 00 A9. LDA #$55 0201 00 55. 0202 00 A2. LDX #$44 0203 00 44. 0204 00 00. BRK 0205 00 0200 0200 A9 G KIM 0206 00 EF 00EF 06 00F0 02 00F1 30 00F2 00 00F3 55 00F4 00 00F5 44
As you can see, the BRK at 0205 has made the CPU jump to SAVE:
– EF has the Program counter 0206 (the first location after the BRK)
F3 has A, 55
F5 has X, 44
Now you can replace the BRK at 0205 with what was originally there and continue at 0205. Or start with Single Stepping by sliding SST swicth to ON.