Specifications

Table Of Contents
Altera Corporation 3–13
October 2007 Nios II Processor Reference Handbook
Programming Model
access to the code memory to read this address). If the instruction is trap,
the exception is a software trap. If the instruction at address ea-4 is one
of the instructions that can be implemented in software, the exception
was caused by an unimplemented instruction. See “Potential
Unimplemented Instructions” on page 3–21 for details. If none of the
above conditions apply, the exception type is unrecognized, and the
exception handler should report the condition.
Nested Exception Precautions
Exception routines must take special precautions before:
Issuing a trap instruction
Issuing an unimplemented instruction
Re-enabling hardware interrupts
Before allowing any of these actions, the exception routine must save
estatus and ea (r29), then restore them properly before returning to
preserve the pre-exception state of the exception registers.
Returning From Interrupt and Instruction-Related Exceptions
The eret instruction is used to resume execution at the pre-exception
address. Except for the et register (r24), the exception routine must
restore any registers modified during exception processing before
returning.
When executing the eret instruction, the processor:
1. Copies the contents of estatus to status
2. Transfers program execution to the address in the ea register (r29)
Return Address Considerations
The return address requires some consideration when returning from
exception processing routines. After an exception occurs, ea contains the
address of the instruction after the point where the exception occurred.
When returning from instruction-related exceptions, execution must
resume from the instruction following the instruction where the
exception occurred. Therefore, ea contains the correct return address.