HomeARM CourseDay 17
DAY 17 · SYSTEM & MEMORY

Exceptions & Interrupts — IRQ, FIQ & the Vector Table

By EcrioniX · Updated Jun 6, 2026

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.

1. Exception vs interrupt

People use the words interchangeably, but there's a hierarchy:

So: every interrupt is an exception, but not every exception is an interrupt.

2. The classic ARM exceptions

ExceptionCauseMode entered
Resetpower-on / hard resetSupervisor
Undefinedunknown instructionUndefined
SVC (SWI)software interrupt — call into the OSSupervisor
Prefetch abortbad instruction fetchAbort
Data abortbad data accessAbort
IRQnormal hardware interruptIRQ
FIQfast hardware interruptFIQ

These tie straight back to the operating modes from Day 5 — each exception drops the core into a specific privileged mode.

3. The vector table

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:

; Classic ARM vector table (one instruction per entry) _vectors: B reset_handler ; 0x00 Reset B undef_handler ; 0x04 Undefined instruction B svc_handler ; 0x08 Software interrupt (SVC) B pabort_handler ; 0x0C Prefetch abort B dabort_handler ; 0x10 Data abort ; 0x14 (reserved) B irq_handler ; 0x18 IRQ B fiq_handler ; 0x1C FIQ ← last, so the handler can start right here

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.

4. IRQ vs FIQ — why two?

IRQFIQ (Fast Interrupt)
Prioritynormalhigher
Banked registersr13, r14r8–r14 (more)
Latencylowlowest
Typical usemost peripheralsthe 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.

5. What the core does automatically on entry

The hardware does several things for you the instant an exception is taken:

  1. Switches mode (e.g. into IRQ mode), changing which banked SP/LR are visible.
  2. Saves CPSR → SPSR of the new mode, so the old processor state is preserved.
  3. Saves the return address into the mode's banked LR.
  4. Disables further interrupts as appropriate (e.g. masks IRQ; FIQ masks both).
  5. Jumps to the vector for that exception.

Banked registers (Day 5) are what make this cheap — the handler gets its own SP and LR without touching the interrupted program's.

6. Returning from an exception

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:

irq_handler: SUB lr, lr, #4 ; adjust return address (IRQ) PUSH {r0-r3, lr} ; save scratch regs we'll use ; ... handle the interrupt (clear the peripheral flag!) ... LDM sp!, {r0-r3, pc}^ ; return: restore regs, PC, and CPSR (the ^)

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.

✅ The mental model

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.

🎯 Day 17 takeaways

Quick check

  1. Why is every interrupt an exception but not vice-versa?
  2. Name two reasons FIQ has lower latency than IRQ.
  3. What does the ^ do on an exception-return LDM?

FAQ

Exception vs interrupt?

An exception is any diversion to a handler (reset, fault, SVC, interrupt); an interrupt is specifically a hardware-raised exception.

IRQ vs FIQ?

FIQ is the fast, higher-priority interrupt with extra banked registers (r8–r14) and its vector last, for the most time-critical source.

What's the vector table?

A fixed array of per-exception entries (usually at 0x0) the core jumps to when an exception occurs.

Previous
← Day 16: The Thumb instruction set

← Back to the full course roadmap