
ML674001 Series/ML675001 Series User’s Manual
Chapter 2 CPU
2-11
2.12 Exceptions
An exception indicates the need to temporarily suspend normal program flow--to process an interrupt request from
a peripheral. The CPU must therefore save the current CPU state before switching to the exception handler and
subsequently restore it when the handler returns.
If there are simultaneous exceptions, a fixed priority system determines the order in which they are accepted. For
further details, see Section 2.12.10 “Exception Priority Order.”
2.12.1
Switching to Exception Handler
Switching to an exception handler involves the following operations.
1.
The CPU saves the return address in the corresponding link register (R14_xxx).
This return address is the current program counter (PC) contents plus an offset (2, 4, or 8) depending on
the exception type and the CPU state at the time of the exception. For further details, see Table 2.2
“Returning from Exception Handlers.”
In the ARM state, the return address is simply the address of the next instruction. In the THUMB state,
however, the offset sometimes changes to allow the exception handler to return with the same
instruction--MOVS PC, R14_svc for a software interrupt, for example--regardless of the original state.
2.
The CPU copies the current program status register (CPSR) contents to the corresponding save program
status register (SPSR_xxx).
3.
The CPU sets the CPSR mode bits to the exception handler's operating mode.
To prevent multiple exceptions from interfering with proper system control, the hardware also sets both
interrupt disable bits to “1.”
4.
The CPU loads the exception handler's entry point from the corresponding exception vector into PC to
transfer control.
If the CPU is in the THUMB state, this step simultaneously switches it to the ARM state.
2.12.2
Returning from Exception Handler
Returning from an exception handler involves the following operations.
1.
The CPU subtracts the specified offset (0, 4, or 8) from the link register contents and loads the result into
the program counter (PC). This offset depends on the exception type.
2.
The CPU copies the save program status register (SPSR_x) contents back into the current program
status register (CPSR).
Note
This copy restores the interrupt disable bits to the states that they had prior to the exception. It also
restores the T bit, so it is not necessary for the software to switch back to the THUMB state.