Exception and Interrupt Handling
Embedded XINU utilizes a interrupt handling system which allows components to register custom interrupt handlers to the system at runtime or use the default trap handler.
Since interrupt handling code can occupy at most 0x20 bytes of memory in the reserved system area, the interrupt handler must be efficient and robust. When an exception occurs the handler checks the cause register for the number of the exception, loads the known offset to the interrupt vector table (0x8000 0200) and adds the exception number to that offset. After the address of the exception handler is known, it is loaded into a register, checks if it is the NULL pointer (not set) and jumps to the handler code. If the handler is set to NULL, the code uses the default trap handler instead.
Interrupt handling occurs in a similar fashion, but relies on saving the state of the system which cannot occur in the simple interrupt handler.