Rev. 1.50, 10/04, page 302 of 448
10.1.57 RTE (Return from Exception): System Control Instruction
Format Operation Instruction Code Cycle T Bit
RTE SSR → SR, SPC→ PC 0000000000101011 4 —
Description: This instruction returns from an exception or interrupt handling routine by restoring
the PC and SR values from SPC and SSR. Program execution continues from the address specified
by the restored PC value.
RTE is a privileged instruction, and can only be used in privileged mode. Use of this instruction in
user mode will cause an illegal instruction exception.
Notes: As this is a delayed branch instruction, the instruction following the RTE instruction is
executed before the branch destination instruction.
Interrupts are not accepted between this instruction and the following instruction. An exception
must not be generated by the instruction in this instruction's delay slot. If the following instruction
is a branch instruction, it is identified as a slot illegal instruction.
If this instruction is located in the delay slot immediately following a delayed branch instruction, it
is identified as a slot illegal instruction.
The SR value accessed by the instruction in the RTE delay slot is the value restored from SSR by
the RTE instruction. The SR and MD values defined prior to RTE execution are used to fetch the
instruction in the RTE delay slot.
Operation:
RTE( ) /* RTE */
{
unsigned int temp;
temp = PC;
SR = SSR;
PC = SPC;
Delay_Slot(temp+2);
}
Example:
RTE ;Return to original routine.
ADD #8,R14 ;Executed before branch.