Code: Select all
1. Determine source of interrupt
2. Record an event of some kind indicating what happened.
3. Return as fast as I possibly can.
Eliminating the reentrancy, you will need to write your interrupt service routine as a coroutine rather than a subroutine:
Code: Select all
ISR_EXIT:
RTI ; return to user program, including CPU state.
; When an interrupt triggers again, execution picks up here.
ISR_ENTRY:
JSR isItVia1
JSR isItVia2
JSR isItAcia
JMP ISR_EXIT
Alternatively, if you prefer the subroutine model, you can just have an interrupt force-load PC with a special I_PC register value, and save the PC in R_PC or some such. That way, if you want re-entrancy, you can do this:
Code: Select all
ISR_ENTRY:
PHR ; push R_PC
PHF ; push R_P (user "f"lags)
SEI ; re-enable interrupts
...process normally, including explicitly saving any other state...
PLF
PLR
RTI
_RESET:
...etc...
LDA #ISR_ENTRY
PHA
PLI ; load I_PC register -- safe to enable IRQ now.
...etc...