
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Exception Handling in MIPS documents
Typology: Study notes
1 / 1
This page cannot be seen from the preview
Don't miss anything!

MIPS exceptions are handled by a peripheral device to the CPU called coprocessor 0 (cp0). Coprocessor 0 contains a number of registers used to configure exception handling and to report the status of current exceptions.
MAL has no aliases for the cp0 registers, so they must be referred to as register numbers. For example, the status register is referred to as $12.
Registers in coprocessor 0 cannot be used directly by MIPS instructions. Instead, there are two instructions that work much like load and store instructions. The mfc0 (move from coprocessor 0) instruction loads data from a coprocessor 0 register into a CPU register. The mtc0 likewise stores data in a cp0 register.
Note
The mtc0 instruction, like the store instruction has the destination last. This is especially important to note, since the syntax for cp0 registers looks the same as the syntax for CPU registers. For example, the following copies the contents of CPU register 13 to cp0 register 12. mtc0 $13, $
Since cp0 registers cannot be accessed by most instructions, changing their values requires using the read-modify-write cycle. This means we must
The read-modify-write cycle is extremely common in interacting with I/O devices and other system hardware.
Exceptions generated by SPIM include overflow and bad address traps, and keyboard and display interrupts.
The SPIM single-step feature cannot be used with exception handling. If you are accustomed to using single-stepping for debugging, try using breakpoints instead.