| |||
| Home > Handling Processor Exceptions > About processor exceptions | |||
During the normal flow of execution through a program, the Program Counter (PC) increases sequentially through the address space, with branches to nearby labels or branch with links to subroutines.
Processor exceptions occur when this normal flow of execution is diverted, to enable the processor to handle events generated by internal or external sources. Examples of such events are:
externally generated interrupts
an attempt by the processor to execute an undefined instruction
accessing privileged operating system functions.
Figure 6.1 shows the exception handling process.
When an exception occurs, control passes through an area of memory called the vector table. This is a reserved area usually at the bottom of the memory map. Within the table one word is allocated to each of the various exception types. This word contains either a branch instruction or, in the case of ARMv6-M and ARMv7-M, an address to the relevant exception handler.
You can write the exception handlers in either ARM or Thumb®-2 code if the processor supports
the respective instruction set. For the ARMv7-M and ARMv6-M profiles,
the processor enters the exception handler that is specified in
the vector table. For all other ARM processors, you must branch
from the top-level handler to the code that handles the exception.
Use a Branch and exchange (BX)
if state change is required (see Chapter 5 Interworking ARM and Thumb for more information). When handling
exceptions, the current processor mode, state, and registers must
be preserved so that the program can resume when the appropriate
exception handling routine completes.