← Back to the chapter · Previous detail
Technical detail · Microcontroller Programming: Timing and Reliability
Cortex-M status registers
On Cortex-M4, xPSR is the combined view of three overlapping status-register roles: the Application Program Status Register (APSR), Interrupt Program Status Register (IPSR), and Execution Program Status Register (EPSR).
Saturating arithmetic clamps a result to the allowed range instead of wrapping; DSP operations are instructions used for signal-processing tasks such as packed arithmetic. Thumb is the instruction set used by Cortex-M. ICI records progress for certain interrupted instructions, while IT tracks conditional execution in a Thumb instruction block. These fields help the processor resume work correctly.
| View / field | Bit(s) | Meaning |
|---|---|---|
APSR N | 31 | Negative: the result’s most significant bit is one |
APSR Z | 30 | Zero: the result is zero |
APSR C | 29 | Carry/borrow/shift carry; interpret subtraction using Arm’s no-borrow convention |
APSR V | 28 | Signed overflow: the signed mathematical result did not fit |
APSR Q | 27 | Sticky saturation flag set by saturating/DSP operations until software clears it as permitted |
| IPSR exception number | 8:0 | Zero means Thread mode; nonzero identifies the active exception |
EPSR T | 24 | Thumb execution state; Cortex-M executes Thumb instructions and an invalid state faults |
EPSR ICI/IT | split across 26:25 and 15:10 | Interrupt-continuable instruction state or Thumb IT conditional-execution state |
The arithmetic flags are easiest to separate with two examples. 0xFFFFFFFF + 1 produces zero, so Z=1 and C=1; interpreted as signed , it does not overflow, so V=0. By contrast, 0x7FFFFFFF + 1 produces 0x80000000: N=1, V=1, and C=0. Carry describes the unsigned result, while overflow describes the signed result.
IPSR gives exception context, not a generic interrupt-enabled flag. Handler mode has a nonzero exception number; Thread mode reads zero. EPSR’s ICI/IT fields are execution-resume state maintained by the processor around interrupted multi-cycle instructions or IT blocks. Application code should not treat them as spare flags. When a debugger shows xPSR, decode each view by its own meaning: arithmetic result in APSR, active exception in IPSR, and execution state in EPSR.
Decode processor status by question, not as one opaque hexadecimal word, in the diagram Figure 5.
In this snapshot, choose the field that answers the debugging question: APSR for arithmetic, IPSR for exception identity, or EPSR for execution state.