
10. Interrupts
10.6.6
Saving a Register
In the interrupt sequence, the FLG register and PC are pushed onto the stack.
Figure 10.8 shows the stack states before and after an interrupt request is acknowledged.
Other registers can be saved by program at the beginning of the interrupt routine. The PUSHM instruction can
save several registers(1) in the register bank currently used.
NOTE:
1. Selectable from registers R0, R1, R2, R3, A0, A1, SB, and FB.
Figure 10.8
Stack States Before and After Acknowledgement of Interrupt Request
10.6.7
Returning from Interrupt Routine
When the REIT instruction is executed at the end of an interrupt routine, the FLG register and PC, which have
been pushed onto the stack before the interrupt sequence is performed, are automatically restored. And then, the
program that was running before an interrupt request was acknowledged, resumes its process. Refer to 10.4 Before executing the REIT or FREIT instructions, use the POPM instruction or the like to restore registers
saved by program in an interrupt routine. By executing the REIT or FREIT instruction, register bank is
switched back to the one used immediately before the interrupt sequence.
[SP]
SP value before
an interrupt is
generated
Stack state before an interrupt
request is acknowledged
Stack state after an interrupt
request is acknowledged
PCL: 8 low-order bits of PC
PCM: 8 middle-order bits of PC
PCH: 8 high-order bits of PC
FLGL: 8 low-order bits FLG
FLGH: 8 high-order bits of FLG
Address
m
m - 1
m - 2
m - 3
m - 4
m + 1
m - 5
m - 6
Previous stack
contents
Previous stack
contents
Stack
MSB
LSB
00h
FLGL
Previous stack
contents
PCH
Previous stack
contents
[SP]
New SP value
m + 1
Address
Stack
PCM
PCL
MSB
LSB
m - 5
m - 6
m
m - 1
m - 2
m - 3
m - 4
FLGH