SNIU028D February 2016 – September 2020 UCD3138 , UCD3138064 , UCD3138064A , UCD3138128 , UCD3138A , UCD3138A64
The ARM processor has seven processor operating modes, as shown in Table 14-1. Each operating mode is used for a particular purpose; only one mode is in use at any one time:
Mode | Privileged | Purpose |
---|---|---|
User | No | The common mode for running most routines |
Fast Interrupt (FIQ) | Yes | The mode for executing time critical tasks |
Standard Interrupt (IRQ) | Yes | The mode for executing time sensitive tasks |
System | Yes | Privileged, using same User mode registers |
Supervisor | Yes | The mode after a reset, and the mode for execution of software interrupt (SWI) |
Abort | Yes | The mode for memory access violation exception |
Undefined | Yes | The mode for undefined instruction exception |
Among other things, the operating modes shown in Table 14-1 define the registers that can be used (also called the register map) and the operating privilege level.
The ARM processor has a simple privilege model: all modes are privileged apart from User mode. Privilege is the ability to perform certain tasks that cannot be done from User mode. For example, changing the operating mode is a privileged operation.
The ARM processor has a total of 37 registers: 31 general-purpose registers (including the Program Counter R15) and 6 status registers. These registers are shown in Table 14-2.
User | System | Fast Interrupt | Interrupt | Supervisor | Abort | Undefined |
---|---|---|---|---|---|---|
R0 | R0 | R0 | R0 | R0 | R0 | R0 |
R1 | R1 | R1 | R1 | R1 | R1 | R1 |
R2 | R2 | R2 | R2 | R2 | R2 | R2 |
R3 | R3 | R3 | R3 | R3 | R3 | R3 |
R4 | R4 | R4 | R4 | R4 | R4 | R4 |
R5 | R5 | R5 | R5 | R5 | R5 | R5 |
R6 | R6 | R6 | R6 | R6 | R6 | R6 |
R7 | R7 | R7 | R7 | R7 | R7 | R7 |
R8 | R8 | R8_fiq | R8 | R8 | R8 | R8 |
R9 | R9 | R9_fiq | R9 | R9 | R9 | R9 |
R10 | R10 | R10_fiq | R10 | R10 | R10 | R10 |
R11 | R11 | R11_fiq | R11 | R11 | R11 | R11 |
R12 | R12 | R12_fiq | R12 | R12 | R12 | R12 |
R13 (SP) | R13 (SP) | R13_fiq | R13_irq | R13_svc | R13_abt | R13_und |
R14 (LR) | R14 (LR) | R14_fiq | R14_irq | R14_svc | R14_abt | R14_und |
R15 (PC) | R15 (PC) | R15 (PC) | R15 (PC) | R15 (PC) | R15 (PC) | R15 (PC) |
Program Status Registers | ||||||
CPSR | CPSR | CPSR | CPSR | CPSR | CPSR | CPSR |
SPSR_fiq | SPSR_irq | SPSR_svc | SPSR_abt | SPSR_und | ||
Register | Indicates that the normal register used by User or System mode has been replaced by an alternative register specific to the mode of operation. |
As shown in Table 14-2, each processor mode has its own R13 and R14 registers. This allows each mode to maintain its own stack pointer and return address. In addition, the Fast Interrupt (FIQ) mode has additional registers: R8–R12. This means that when the ARM processor switches into FIQ mode, the software does not need to save the normal R8–R12 registers, as FIQ mode has its own set that can be modified.
The Current Program Status Register (CPSR) is used to store condition code flags, interrupt disable bits, the current processor mode and other status and control information. This register is depicted in Table 14-3:
31 | 30 | 29 | 28 | 27 | 24 | 23 | 16 |
N | Z | C | V | Undefined | Undefined |
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Undefined | I | F | T | Mode |
The Current Program Status Register is defined in the following way:
As mentioned above, bits 24–31, the condition code flags, can be modified in any mode. Bits 0–23 can only be modified in a privileged mode (i.e., any mode other than User mode). Table 14-2 shows the individual bit patterns needed in bits 0–4 to use a particular mode:
Mode Bit | Processor Mode (Abbreviation) | Accesible Registers | |
---|---|---|---|
Bin | Hex | ||
10000 | 10 | User (usr) | PC, R14-R0, CPSR |
10001 | 11 | Fast Interrupt (fiq) | PC, R14_fiq-R8_fiq, R7-R0, CPSR, SPSR_fiq |
10010 | 12 | Interrupt (irc) | PC, R14_irq, R13_irq, R12-R0, CPSR, SPSR_irq |
10011 | 13 | Supervison (svc) | PC, R14_svc, R13_svc, R12-R0, CPSR, SPSR_svc |
10111 | 17 | Abort (abt) | PC, R14_abt, R13_abt, R12-R0, CPSR, SPSR_abt |
11011 | 1B | Undefined (und) | PC, R14_und, R13_und, R12-R0, CPSR, SPSR_und |
11111 | 1F | System (sys) | PC, R14-R0, CPSR |
It is worth noting that the five Saved Program Status Registers (SPSRs) have the same format as the Current Program Status Register. These registers save the contents of CPSR when an exception occurs.