220.127.116.11. Returning From Interrupt and Instruction-Related Exceptions
You must ensure that when an exception handler modifies registers, they are restored when it returns. This can be taken care of in either of the following ways:
- In the case of ISRs, if the EIC interface and shadow register sets are implemented, and the ISR has a dedicated register set, no software action is required. The Nios® II processor returns to the previous register set when it executes eret, which restores the register contents.
- For details, refer to the "Nested Exceptions with an External Interrupt Controller" section of this chapter.
- In the case of noninterrupt exceptions, for ISRs in a system with the internal interrupt controller, and for ISRs without a dedicated shadow register set, the exception handler must save registers on entry and restore them on exit. Saving the register contents on the stack is a typical, re-entrant implementation.
When executing the eret instruction, the processor performs the following tasks:
- Restores the previous contents of status as follows:
- If status.CRS is 0, copies estatus to status
- If status.CRS is nonzero, copies sstatus to status
- Transfers program execution to the address in the ea register (r29) in the register set specified by the original value of status.CRS.
Did you find the information on this page useful?