6.3.2. Returning from an exception handler

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:

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 return instruction required depends on the type of exception. See The return address and return instruction for instructions on how to return from each exception type.

Note

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:


    LDMFD sp!,{r0-r12,pc}^

To do this, the exception handler must save the following onto the stack:

The ^ qualifier specifies that the CPSR is restored from the SPSR. It must be used only from a privileged mode. See the description of how to implement stacks with LDM and STM in the RealView Compilation Tools v3.0 Assembler Guide for more general information on stack operations.

Copyright © 2002-2006 ARM Limited. All rights reserved.ARM DUI 0203G
Non-Confidential