rte
Return from exception
Returns from an exception handler by restoring the saved status register and program counter.
- Exceptions and the vector tableM68K assembly
- Interrupts and cyclesM68K assembly
- ● set from the result
Forms
rte
It restores the whole status register, including S. Returning to user mode therefore makes a7 the user stack pointer again. rte requires supervisor mode and raises a privilege violation in user mode. See writing a handler.
On the 68010 and 68020, the saved frame also contains a format word. rte uses it to determine the frame’s size and removes the whole frame. An unsupported format raises a format error.
On the 68020, an interrupt taken while using the master stack leaves a throwaway frame on the interrupt stack. rte removes that frame, switches back to the master stack, and then restores the original frame there. See the throwaway frame.
* --- A handler for a division by zero ---
move.l #div_zero, $14 ; vector 5 is at $14
move.l #100, d0
moveq #0, d1
divu d1, d0 ; d1 is 0, so div_zero runs
move.l d0, d2 ; rte comes back here: d2 = -1
bra END
div_zero:
moveq #-1, d0 ; an answer the program can test
rte ; pops the status register and the return address
END: