Retn – Zilog Z08470 User Manual
Page 299

UM008007-0715
Z80 Instruction Description
Z80 CPU
User Manual
287
RETN
Operation
Return from nonmaskable interrupt
Op Code
RETN
Operands
None.
Description
This instruction is used at the end of a nonmaskable interrupts service routine to restore
the contents of the Program Counter (analogous to the RET instruction). The state of IFF2
is copied back to IFF1 so that maskable interrupts are enabled immediately following the
RETN if they were enabled before the nonmaskable interrupt.
Condition Bits Affected
None.
Example
If the Stack Pointer contains
1000h
and the Program Counter contains
1A45h
when a
Nonmaskable Interrupt (NMI) signal is received, the CPU ignores the next instruction and
instead restarts, returning to memory address
0066h
. The current Program Counter con-
tains
1A45h
, which is pushed onto the external stack address of
0FFFh
and
0FFEh
, high-
order byte first, and
0066h
is loaded onto the Program Counter. That address begins an
interrupt service routine that ends with a RETN instruction.
Upon the execution of a RETN instruction, the contents of the former Program Counter
are popped off the external memory stack, low-order first, resulting in the Stack Pointer
again containing
1000h
. The program flow continues where it left off with an op code
fetch to address
1A45h
, order-byte first, and
0066h
is loaded onto the Program Counter.
M Cycles
T States
4 MHz E.T.
4
14 (4, 4, 3, 3)
3.50
1
1
0
0
1
1
1
1
ED
0
1
0
0
1
1
0
0
45