Exceptions are conditions which alter the normal sequence of instructions, causing the processor to transfer control to a predefined location in memory, the so-called exception vector. In the MIPS1 base architecture there is a single exception vector, the General Exception Vector, whose virtual address depends on the setting of the Status Register's Bootstrap Exception Vector (BEV) bit, as shown in Table 4.1 and described later in this chapter.
The MIPS architecture recognizes seventeen exceptions: eight external interrupts (six hardware interrupts and two software interrupts), and nine program exception conditions (sometimes referred to as 'traps'). The type of exception is encoded in the Exception Code (ExcCode) field of the Cause Register, as shown in Table 4.2.
Table 4.1 General Exception Vector Addresses
BEV = 1
(Reset State) BEV = 0
Virtual Address Oxbfc0.0180 (kseg1) 0x8000.0080 (kseg0)
Physical Address 0x1fc0.0180 0x0000.0080
Table 4.2 ExcCode Field in Cause Register
ExcCode Assembler Exception Type Value Mnemonic
0 EXC_INT External interrupt 1 - Reserved 2 - Reserved 3 - Reserved 4 EXC_ADEL Address error (load or instruction fetch) 5 EXC_ADES Address error (data store) 6 EXC_IBE Bus error (instruction fetch) 7 EXC_DBE Bus error (data load or store) 8 EXC_SYS Syscall instruction 9 EXC_BP Breakpoint 10 EXC_RI Reserved instruction 11 EXC_CPU Coprocessor Unusable 12 EXC_OVF Arithmetic overflow 13-15 Not used.
When an exception occurs, the following events take place:
When the exception handler has completed, it uses the address in the EPC register as the return address in a jump, and then executes a Return From Exception (rfe) instruction in the jump's delay slot. The rfe instruction restores the Current and Previous Mode and Interrupt Enable bits to their contents prior to the interrupt, leaving the Old bits unchanged.