NMI and IRQ and BRK

NMI, BRK and IRQ handling

The 6502 NMI interrupt is available as ST key on the hex keyboard vai a NE556 debounce circuit.

The IRQ line is unconnected (quiet via a resistor pull)

The 6502 vectors are:

1213   1FFA 1C 1C       NMIENT  .WORD NMIT
1214   1FFC 22 1C       RSTENT  .WORD RST
1215   1FFE 1F 1C       IRQENT  .WORD IRQT

For RESET handling see here.

0602   1C1C             ;             
0603   1C1C 6C FA 17    NMIT    JMP   (NMIV)     ; NON-MASKABLE INTERRUPT TRAP 
0604   1C1F 6C FE 17    IRQT    JMP   (IRQV)     ; INTERRUPT TRAP 

These entries are not initialized by the KIM-1 monitor, that is up to the user.

The interrupt handler, saves all CPU registers at the relevant zeropage locations and restarts the KIM- monitor.

0587   1C00 85 F3       SAVE    STA   ACC        ; KIM ENTRY VIA STOP (NMI) 
0588   1C02 68                  PLA              ; OR BRK (IRQ)
0589   1C03 85 F1               STA   PREG
0590   1C05 68                  PLA              ; KIM ENTRY VIA JSR (A LOST) 
0591   1C06 85 EF               STA   PCL
0592   1C08 85 FA               STA   POINTL
0593   1C0A 68                  PLA   
0594   1C0B 85 F0               STA   PCH
0595   1C0D 85 FB               STA   POINTH
0596   1C0F 84 F4               STY   YREG
0597   1C11 86 F5               STX   XREG
0598   1C13 BA                  TSX   
0599   1C14 86 F2               STX   SPUSER
0600   1C16 20 88 1E            JSR   INITS
0601   1C19 4C 4F 1C            JMP   START

To use the NMI line one must fill the NMI vector at 17FA. For SST and ST key this has to hold $1C00, the SAVE routine.

To use a hardware IRQ or a BRK instruction the IRQ vector at 17FE has to be filled, SAVE $1C00 is the recommended vector.