world leader in high performance signal processing
Trace: » return

RTS, RTI, RTX, RTN, RTE (Return)

General Form

RTS, RTI, RTX, RTN, RTE

Syntax

RTS ; // Return from Subroutine (a)
RTI ; // Return from Interrupt (a)
RTX ; // Return from Exception (a)
RTN ; // Return from NMI (a)
RTE ; // Return from Emulation (a)

Instruction Length

In the syntax, comment (a) identifies 16-bit instruction length.

Functional Description

The Return instruction forces a return from a subroutine, maskable or NMI interrupt routine, exception routine, or emulation routine.

Mnemonic Description
RTS Forces a return from a subroutine by loading the value of the RETS Register into the Program Counter (PC), causing the processor to fetch the next instruction from the address contained in RETS. For nested subroutines, you must save the value of the RETS Register. Otherwise, the next subroutine CALL instruction overwrites it.
RTI Forces a return from an interrupt routine by loading the value of the RETI Register into the PC. When an interrupt is generated, the processor enters a non-interruptible state. Saving RETI to the stack re-enables interrupt detection so that subsequent, higher priority interrupts can be serviced (or “nested”) during the current interrupt service routine. If RETI is not saved to the stack, higher priority interrupts are recognized but not serviced until the current interrupt service routine concludes. Restoring RETI back off the stack at the conclusion of the interrupt service routine masks subsequent interrupts until the RTI instruction executes. In any case, RETI is protected against inadvertent corruption by higher priority interrupts.
RTX Forces a return from an exception routine by loading the value of the RETX Register into the PC.
RTN Forces a return from a non-maskable interrupt (NMI) routine by loading the value of the RETN Register into the PC.
RTE Forces a return from an emulation routine and emulation mode by loading the value of the RETE Register into the PC. Because only one emulation routine can run at a time, nesting is not an issue, and saving the value of the RETE Register is unnecessary.

Flags Affected

None

Required Mode

Mnemonic Required Mode
RTS User & Supervisor
RTI, RTX, and RTN Supervisor only. Any attempt to execute in User mode produces a protection violation exception.
RTE Emulation only. Any attempt to execute in User mode or Supervisor mode produces an exception.

Parallel Issue

This instruction cannot be issued in parallel with other instructions.

Example

rts ;
rti ;
rtx ;
rtn ;
rte ;

Also See

Special Applications

None