IT lexicon › Hardware › EXC_RETURN

EXC_RETURN

Hardware På svenska → Updated: 2026-11-05

The magic value Cortex-M puts in the link register on exception entry, turning an ordinary function return into an exception return.

When an exception is taken, the hardware stacks eight registers by itself and loads LR with something like 0xFFFFFFF9 or 0xFFFFFFFD. When the handler later returns with BX LR or POP {PC}, the core spots the address — nothing executable lives there — and unstacks the frame instead. That's why an interrupt service routine on Cortex-M can be a perfectly plain C function with no compiler attributes.

The bits encode where to go back to: thread or handler mode, MSP or PSP, and on cores with an FPU, whether the frame includes floating-point registers (see lazy stacking). An RTOS rewrites it in PendSV when switching tasks. Clobber LR by accident and you get a HardFault with a thoroughly confusing stack trace.

← Back to the lexicon