I've run into a bit of a snag with some NMI code for the SBC I've built (based on Daryl Rictor's board). I'm creating a programmer's "panic" button that returns code execution to the monitor program...the code will never return to where it was originally executing.
I connected one of the VIAs to /NMI, configured CA1 with a pull-up resistor and a push button switch to ground, and configured and armed the correct interrupt -- this is how Commodore did it for the RUN/STOP-RESTORE combination, although I'm using only one switch.
Here is the NMI handler code:
Code: Select all
NMIVEC
SEI
PHA ;save regs
TXA
PHA
TYA
PHA
LDA D1IFR ;check VIA interrupt flag
BPL WARMEOI ;no flag, then issue EOI
WARM1
; LDA D1IER ;get IER bitmap
; ORA #%10000010 ;$80 set mask for enabling interrupts
; PHA ; according to existing bitmap
; LDA #%01111111 ;$7F mask - disable all VIA1 interrupts
; STA D1IER
; PLA
; STA D1IER ; re-arm interrupts
PLA ;restore registers
TAY
PLA
TAX
PLA
CLI
JMP Monitor ; monitor warm-start entry
WARMEOI
PLA ;restore registers
TAY
PLA
TAX
PLA
RTI ;return from interrupt
I did read the Interrupts tutorial and other than my interrupt disable and the method of re-arming the interrupt, the code is pretty simple.
Any nudge in the right direction would be appreciated. Thanks!