CHAPTER 5 INTERRUPT/EXCEPTION PROCESSING FUNCTION
User’s Manual U13850EJ6V0UD
157
5.3.2 Restore
To restore execution from maskable interrupt servicing, the RETI instruction is used.
Operation of RETI instruction
When the RETI instruction is executed, the CPU performs the following steps, and transfers control to the address
of the restored PC.
(1) Restores the values of the PC and PSW from EIPC and EIPSW because the EP bit of the PSW is 0 and the
NP bit of PSW is 0.
(2) Transfers control to the address of the restored PC and PSW.
The processing of the RETI instruction is shown below.
Figure 5-5. RETI Instruction Processing
RETI instruction
Restores original processing
PC
PSW
EIPC
EIPSW
PSW. EP
1
0
1
0
PC
PSW
FEPC
FEPSW
PSW. NP
Caution
When the PSW.EP bit and the PSW.NP bit are changed by the LDSR instruction during maskable
interrupt servicing, in order to restore the PC and PSW correctly during recovery by the RETI
instruction, it is necessary to set PSW.EP back to 0 and PSW.NP back to 0 using the LDSR
instruction immediately before the RETI instruction.
Remark
The solid line shows the CPU processing flow.