Programmer’s Model
ARM DDI 0301H
Copyright © 2004-2009 ARM Limited. All rights reserved.
2-38
ID012310
Non-Confidential, Unrestricted Access
2.12.3
Entering an ARM exception
SCR[3:1] determine the mode that the processor enters on an FIQ, IRQ, or external abort
exception, see
System control and configuration
on page 3-5.
When handling an ARM exception the processor:
1.
Preserves the address of the next instruction in the appropriate LR. When the exception
entry is from:
ARM and Jazelle states:
The processor 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.
Thumb state:
The processor writes the value of the PC into the LR, offset by a value, current
PC + 2, 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 have to determine the state when entering an exception.
For example, in the case of a SVC,
MOVS PC, R14_svc
always returns to the next instruction
regardless of whether the SVC was executed in ARM or Thumb state.
2.
Copies the CPSR into the appropriate SPSR.
3.
Forces the CPSR mode bits to a value that depends on the exception.
4.
Forces the PC to fetch the next instruction from the relevant exception vector.
The processor can also set the interrupt and imprecise abort 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 or Jazelle state and an exception occurs, the switch to ARM state takes place
automatically when the exception vector address is loaded into the PC.
2.12.4
Leaving an ARM 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 Table 2-8 on page 2-37 lists.
Typically the return instruction is an arithmetic or logical operation with the S bit set and rd =
R15, so the core copies the SPSR back to the CPSR.
Note
The action of restoring the CPSR from the SPSR automatically resets the T bit and J bit to the
values held immediately prior to the exception. The A, I, and F bits are also automatically
restored to the value they held immediately prior to the exception.
2.12.5
Reset
When the
nRESETIN
and
nVFPRESETIN
signals are driven LOW a reset occurs, and the
processor abandons the executing instruction.