Until now your code ran top to bottom. But real systems must react — a timer fires, a button is pressed, an instruction faults. The mechanism that lets the processor drop everything, handle the event, and resume exactly where it left off is the exception. Get this right and your firmware comes alive.
People use the words interchangeably, but there's a hierarchy:
SVC), or a hardware interrupt.So: every interrupt is an exception, but not every exception is an interrupt.
| Exception | Cause | Mode entered |
|---|---|---|
| Reset | power-on / hard reset | Supervisor |
| Undefined | unknown instruction | Undefined |
| SVC (SWI) | software interrupt — call into the OS | Supervisor |
| Prefetch abort | bad instruction fetch | Abort |
| Data abort | bad data access | Abort |
| IRQ | normal hardware interrupt | IRQ |
| FIQ | fast hardware interrupt | FIQ |
These tie straight back to the operating modes from Day 5 — each exception drops the core into a specific privileged mode.
When an exception fires, the core doesn't search for a handler — it jumps to a fixed address reserved for that exception. The block of these fixed addresses is the vector table, usually at address 0x00000000. In classic ARM each slot holds one instruction, almost always a branch to the real handler:
FIQ sits last on purpose: there's nothing after it, so the FIQ handler code can begin immediately at the vector with no extra branch — shaving cycles off the fastest interrupt.
| IRQ | FIQ (Fast Interrupt) | |
|---|---|---|
| Priority | normal | higher |
| Banked registers | r13, r14 | r8–r14 (more) |
| Latency | low | lowest |
| Typical use | most peripherals | the one most time-critical source |
FIQ has extra banked registers (r8–r14), so its handler has private scratch registers it can use without pushing/popping the interrupted code's values — less save/restore means lower latency. You typically reserve FIQ for a single critical source (e.g. a motor controller) and route everything else through IRQ.
The hardware does several things for you the instant an exception is taken:
Banked registers (Day 5) are what make this cheap — the handler gets its own SP and LR without touching the interrupted program's.
Returning isn't a plain BX LR, because you must restore both the PC and the saved status (SPSR → CPSR) atomically, and adjust for pipeline offset. ARM provides special forms:
The ^ on the load-to-PC tells the core to also restore CPSR from SPSR. On Cortex-M this is all handled differently and far more automatically — which is exactly tomorrow's topic, the NVIC.
An exception is a hardware-driven function call: the core saves your state, switches to a privileged mode, and jumps to a fixed vector. IRQ is the everyday interrupt; FIQ is the privileged fast lane with extra banked registers. Your handler does the work and returns by restoring both PC and CPSR together.
LDM sp!, {…, pc}^).^ do on an exception-return LDM?An exception is any diversion to a handler (reset, fault, SVC, interrupt); an interrupt is specifically a hardware-raised exception.
FIQ is the fast, higher-priority interrupt with extra banked registers (r8–r14) and its vector last, for the most time-critical source.
A fixed array of per-exception entries (usually at 0x0) the core jumps to when an exception occurs.