
5. CPU Exception Processing

The processor then disables interrupts and forces execution of a software exception processor (called a handler) located at a fixed address. The handler saves the context of the processor, including the contents of the program counter, the current operating mode (User or Supervisor), and the status of the interrupts (enabled or disabled). This context is saved so it can be restored when the exception has been serviced.
When an exception occurs, the CPU loads the Exception Program Counter (EPC) register with a location where execution can restart after the exception has been serviced. The restart location in the EPC register is the address of the instruction that caused the exception or, if the instruction was executing in a branch delay slot, the address of the branch instruction immediately preceding the delay slot.
The registers described later in the chapter assist in this exception processing by retaining address, cause and status information.
For a description of the exception handling process, see the description of the individual exception contained in this chapter, or the flowcharts at the end of this chapter.





Generated with CERN WebMaker
![]()