This describes the processor response to an exception, and how to return to the main program after the exception has been handled. You must ensure that the exception handler saves the system state when an exception occurs and restores it on return.
The method used to return from an exception depends on whether the exception handler uses stack operations or not. In both cases, to return execution to the place where the exception occurred an exception handler must:
restore the CPSR from the appropriate SPSR
restore the PC using the return address from the appropriate LR.
For a simple return that does not require the destination mode registers to be restored from the stack, the exception handler carries out these operations by performing a data processing instruction with:
the S flag set
the PC as the destination register.
The return instruction required depends on the type of exception.
You do not have to return from the reset handler because the reset handler executes your main code directly.
If the exception handler entry code uses the stack to store registers that must be preserved while it handles the exception, it can return using a load multiple instruction with the ^ qualifier. For example, an exception handler can return in one instruction using:
To do this, the exception handler must save the following onto the stack:
all the work registers in use when the handler is invoked
the link register, modified to produce the same effect as the data processing instructions.
^ qualifier specifies that the CPSR
is restored from the SPSR. It must be used only from a privileged
You cannot use any 16-bit Thumb instruction to return from exceptions because these are unable to restore the CPSR.