RETN

Operation

Return from nonmaskable interrupt

Mnemonic

RETN

Operands

none

b7b6b5b4b3b2b1b0
1 1 1 0 1 1 0 1$ED
0 1 0 0 0 1 0 1$45

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 $1000 and the Program Counter contains $1A45 when a Nonmaskable Interrupt (NMI) signal is received, the CPU ignores the next instruction and instead restarts, returning to memory address $0066. The current Program Counter contains $1A45, which is pushed onto the external stack address of $0FFF and $0FFE, high-order byte first, and $0066 is loaded onto the Program Counter. That address begins an interrupt service routine that ends with a

	RETN

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 $1000. The program flow continues where it left off with an op code fetch to address $1A45.