Iret – Zilog Z16F2810 User Manual
Page 126
IRET Instruction
UM018809-0611
110
ZNEO
®
CPU Core
User Manual
IRET
Definition
Interrupt Return
Syntax
IRET
Operation
Normal IRET
Chained IRET
PC
(SP) PC
Pending Interrupt Vector
SP
SP + 4
FLAGS[0]
0
FLAGS[7:0]
+1(SP)
SP
SP + 2
Description
This instruction is issued at the end of an interrupt service routine. It performs one of the follow-
ing two operations:
•
If no interrupts are pending or the Chained Interrupt Enable flag (CIRQE) is 0, execu-
tion of IRET restores the Program Counter and the Flags register from the stack.
•
If one or more vectored interrupts are pending and the CIRQE flag is 1, executing the
IRET instruction passes execution directly to the highest-priority pending interrupt
service routine. The contents of the stack are not changed.
For details about chained interrupts, see the
Returning From a Vectored Interrupt
Any Push or other instructions in the service routine that decrement the stack pointer
must be followed by matching Pop or increment instructions to ensure the Stack Pointer
is at the correct location when IRET is executed. Otherwise, the wrong address loads into
the Program Counter and the program cannot operate properly.
Flags
If IRET executes normally, it restores the Flags register to its state prior to the first interrupt in
the chain.
Caution: