Course: Computer Architectures

Source: R. Ferrero, Politecnico di Torino, 10_exceptions.pdf, 44 PDF pages. The local source remains in Downloads/Architecture/10_exceptions.pdf.

Why this lesson matters

Exceptions temporarily interrupt normal execution so the processor can respond to faults, interrupts, system calls, and timers. Cortex-M hardware saves enough context to resume the interrupted code and uses a vector table plus EXC_RETURN to enter and leave handlers safely.

Learning route

  1. Read ARM Exception Entry and Return for modes, privilege, automatic stacking, vector lookup, and EXC_RETURN.
  2. Read ARM Faults Supervisor Calls and SysTick for fault diagnosis, SVC, and timer interrupts.
  3. Connect the saved stack frame to ARM Stack Conventions and PUSH POP and the earlier Exceptions and Interrupts concept.

Source coverage by PDF page

PDF pagesMaterial
1-5Thread/Handler modes, privilege, CONTROL, and status registers
6-12NVIC, exception entry, automatic stacking, vector table, register updates
13-15EXC_RETURN, exception exit, fault-status and fault-address registers
16-24System exception types, NMI, Hard Fault, Usage Fault, enabling faults
25-33Usage, Bus, and Memory Management Fault examples
34-36SVC and extracting its immediate value
37-44SysTick registers, timing, and configuration

Core exception trace

On entry, the processor stacks r0-r3, r12, LR, PC, and PSR on the active stack, switches to MSP, loads the handler address from the vector table, and places an EXC_RETURN code in LR. The saved PC is at [SP,#24] from the new SP.

A handler returns with BX LR; the special EXC_RETURN value tells the processor whether to restore MSP or PSP and whether to return to Thread or Handler mode.

Source examples and added explanation

The source’s SVC handler selects the stacked frame by testing bit 2 of LR, reads the stacked PC at offset 24, then reads the halfword before that address to recover the SVC immediate. This is an application of the automatic stack-frame layout, not a normal subroutine convention.

Review questions

  • Which registers are automatically stacked on exception entry?
  • Why is the saved PC at offset #24?
  • What information does EXC_RETURN encode?
  • How does an SVC handler discover the requested service number?