R01UH0092EJ0110 Rev.1.10
Page 213 of 807
Jul 31, 2012
M16C/64C Group
14. Interrupts
14.7.5
Saving Registers
In the interrupt sequence, the FLG register and PC are saved on the stack.
At this time, the 4 upper bits of the PC and the 4 upper (IPL) and 8 lower bits in the FLG register, 16 bits
in total, are saved on the stack first. Next, the 16 lower bits of the PC are saved. Figure 14.5 shows the
Stack Status Before and After Acceptance of Interrupt Request.
The other necessary registers must be saved by a program at the beginning of the interrupt routine.
Use the PUSHM instruction, and all registers except SP can be saved with a single instruction.
Figure 14.5
Stack Status Before and After Acceptance of Interrupt Request
The register save operation carried out in the interrupt sequence is dependent on whether the SP
the time of acceptance of an interrupt request, is even or odd. If the SP
is even, the FLG register and
the PC are saved 16 bits at a time. If odd, they are saved in two steps, 8 bits at a time. Figure 14.6
shows the Register Save Operation.
Note:
1.
When an INT instruction with software numbers 32 to 63 has been executed, it is the SP indicated
by the U flag. Otherwise, it is the ISP.
Figure 14.6
Register Save Operation
Address
Contents of previous stack
Stack
[SP]
SP value before
interrupt request is accepted.
m
m - 1
m - 2
m - 3
m - 4
Stack status
before interrupt request is acknowledged
Stack status
after interrupt request is acknowledged
Contents of previous stack
m + 1
MSB
LSB
m
m - 1
m - 2
m - 3
m - 4
Address
FLGL
Contents of previous stack
Stack
FLGH
PCH
[SP]
New SP value
Contents of previous stack
m + 1
MSB
LSB
PCL
PCM
PCL: 8 lower bits of PC
PCM: 8 middle bits of PC
PCH: 4 upper bits of PC
FLGL: 8 lower bits of FLG
FLGH : 4 upper bits of FLG
(2) SP contains odd number
[SP] (Odd)
[SP] - 1 (Even)
[SP] - 2 (Odd)
[SP] - 3 (Even)
[SP] - 4 (Odd)
[SP] - 5 (Even)
Address
Sequence in which
registers are saved
(2)
(1)
Completed saving registers
in four operations.
(3)
(4)
(1) SP contains even number
[SP] (Even)
[SP] - 1 (Odd)
[SP] - 2 (Even)
[SP] - 3 (Odd)
[SP] - 4 (Even)
[SP] - 5 (Odd)
Note:
1. [SP] denotes the initial value of the SP when an interrupt request is acknowledged.
After registers are saved, the SP content is [SP] minus 4.
Address
PCM
Stack
FLGL
PCL
Sequence in which
registers are saved
(2) All 16 bits saved
simultaneously
(1) All 16 bits saved
simultaneously
Completed saving registers
in two operations.
PCM
Stack
FLGL
PCL
Saved 8 bits
at a time
FLGH
PCH
FLGH
PCH
PCL: 8 lower bits of PC
PCM: 8 middle bits of PC
PCH: 4 upper bits of PC
FLGL : 8 lower bits of FLG
FLGH: 4 upper bits of FLG
Содержание M16C Series
Страница 846: ...M16C 64C Group R01UH0092EJ0110...