Excalibur electronic A-MNL-NIOSPROG-01.1 DJ Equipment User Manual


 
18 Altera Corporation
Overview
When a SAVE instruction causes a register window underflow exception,
CWP is decremented only once before control is passed to the exception-
handling subroutine. The underflow exception handler will see CWP
=
LO_LIMIT 1. The register window underflow exception is exception
number 1. The CPU will not process a register window underflow
exception if interrupts are disabled (IE=0) or the current value in IPRI is
less than or equal to 1.
The action taken by the underflow exception-handler subroutine depends
upon the requirements of the system. For systems running larger or more
complex code, the underflow (and overflow) handlers can implement a
virtual register file that extends beyond the limits of the physical register
file. When an underflow occurs, the underflow handler might (for
example) save the current contents of the entire register file to memory
and re-start CWP back at HI_LIMIT, allowing room for code to continue
opening register windows. Many embedded systems, on the other hand,
might wish to tightly control stack usage and subroutine call-depth. Such
systems might implement an underflow handler that prints an error
message and exits the program.
The programmer determines the nature of and actions taken by the
register window underflow exception handler. The Nios software
development kit (SDK) includes, and automatically installs by default, a
register window underflow handler that virtualizes the register file using
the stack as temporary storage.
A register window underflow exception can only be generated by a SAVE
instruction. Directly writing CWP (via a WRCTL instruction) to a value
less than LO_LIMIT will not cause a register window underflow
exception. Executing a SAVE instruction when CWP is already below
LO_LIMIT will not generate a register window underflow exception.
Register Window Overflow
A register window overflow exception occurs whenever the highest valid
register window is in use (CWP = HI_LIMIT) and a RESTORE instruction
is issued. Control is transferred to an exception-handling subroutine
before the instruction following RESTORE is executed.
When a register window overflow exception is taken, the exception
handler will see CWP at HI_LIMIT. You can think of CWP being
incremented by the RESTORE instruction, but then immediately
decremented as a consequence of normal exception processing. The
register window overflow exception is exception number 2.