; NMI behavior when it interrupts IRQ vectoring. ; ; Result when run: ; NMI IRQ ; 23 00 NMI occurs before LDA #1 ; 21 00 NMI occurs after LDA #1 (Z flag clear) ; 21 00 ; 20 00 NMI occurs after CLC, interrupting IRQ ; 20 00 ; 20 00 ; 20 00 ; 20 00 ; 20 00 ; 20 00 Same result for 7 clocks before IRQ is vectored ; 25 20 IRQ occurs, then NMI occurs after SEC in IRQ handler ; 25 20 CUSTOM_IRQ=1 CUSTOM_NMI=1 .include "shell.inc" .include "sync_vbl.s" zp_byte irq_flag ; IRQ sets this to saved flags on stack zp_byte irq_temp zp_byte nmi_flag ; NMI sets this to saved flags on stack zp_byte nmi_temp nmi: ; 7 sta