I am trying to switch normal program flow while an interrupt returns:
START
SEI
LDX #<IRQ
LDY #>IRQ
STX $FFFE
STY $FFFF
CLI
LOOP1
INC $D020
JMP LOOP1
LOOP2
INC $D021
JMP LOOP2
IRQ
STA SAVEA+1
STX SAVEX+1
STY SAVEY+1
// Some Routines
LDA #$00
PHA
LDA #<LOOP2
PHA
LDA #>LOOP2
PHA
SAVEA
LDA #$00
SAVEX
LDX #$00
SAVEY
LDY #$00
RTI
I wrote this code accourding to that source: http://6502.org/tutorials/interrupts.html#1.3
But PHA's cause crash, how to switch normal flow LOOP1 to LOOP2 in an interrupt?
Simple way is:
But for more complex task management, we have to save A,X,Y registers for each task: