
Programmer’s Model
ARM DDI 0165B
Copyright 2000 ARM Limited. All rights reserved.
2-21
2.9.2
Entering an exception
When handling an exception the ARM9E-S:
1.
Preserves the address of the next instruction in the appropriate LR. When the
exception entry is from:
ARM state, the ARM9E-S copies the address of the next instruction into the
LR (current PC + 4 or PC + 8 depending on the exception).
Thumb state, the ARM9E-S writes the value of the PC into the LR, offset
by a value (current PC + 4 or PC + 8 depending on the exception) that
causes the program to resume from the correct place on return.
The exception handler does not need to determine the state when entering an
exception. For example, in the case of a SWI, MOVS PC, r14_svc always
returns to the next instruction regardless of whether the SWI was executed in
ARM or Thumb state.
2.
Copies the CPSR into the appropriate SPSR.
3.
Forces the CPSR mode bits to a value which depends on the exception.
4.
Forces the PC to fetch the next instruction from the relevant exception vector.
The ARM9E-S can also set the interrupt disable flags to prevent otherwise
unmanageable nesting of exceptions.
Note
Exceptions are always entered, handled, and exited in ARM state. When the processor
is in Thumb state and an exception occurs, the switch to ARM state takes place
automatically when the exception vector address is loaded into the PC.
2.9.3
Leaving an exception
When an exception has completed, the exception handler must move the LR, minus an
offset to the PC. The offset varies according to the type of exception, as shown in
If the S bit is set and rd = r15, the core copies the SPSR back to the CPSR and clears
the interrupt disable flags that were set on entry.
Note
The action of restoring the CPSR from the SPSR automatically resets the T bit to the
value it held immediately prior to the exception. The I and F bits are automatically
restored to the value they held immediately prior to the exception.