3.3.2. Overlapping Regions
The memory addresses of regions can overlap. Overlapping regions have several uses
including placing markers or small holes inside of a larger region. For example, the
stack and heap may be located in the same region, growing from opposite ends of the
address range. To detect stack/heap overflows, you can define a small region between
the stack and heap with no access permissions and assign it a higher priority than the
larger region. Any access attempts to the hole region trigger an exception informing
system software about the stack/heap overflow.
If regions overlap so that a particular access matches more than one region, the
region with the highest priority (lowest index) determines the access permissions and
default cacheability.
3.3.3. Enabling the MPU
The MPU is disabled on system reset. System software enables and disables the MPU
by writing to a control register. Before enabling the MPU, you must create at least one
instruction and one data region, otherwise unexpected results can occur. Refer to the
Working with the MPU section for more information.
Related Information
Working with the MPU
on page 68
3.4. Registers
The Nios II register set includes general-purpose registers and control registers. In
addition, the Nios II/f core can optionally have shadow register sets. This section
discusses each register type.
3.4.1. General-Purpose Registers
The Nios II architecture provides thirty-two 32-bit general-purpose registers,
r0
through
r31
. Some registers have names recognized by the assembler. For example,
the
zero
register (
r0
) always returns the value zero, and writing to
zero
has no
effect. The
ra
register (
r31
) holds the return address used by procedure calls and is
implicitly accessed by the
call
,
callr
and
ret
instructions. C and C++ compilers
use a common procedure-call convention, assigning specific meaning to registers
r1
through
r23
and
r26
through
r28
.
Table 11.
The Nios II General-Purpose Registers
Register
Name
Function
Register
Name
Function
r0
zero
0x00000000
r16
Callee-saved register
r1
at
Assembler temporary
r17
Callee-saved register
r2
Return value
r18
Callee-saved register
r3
Return value
r19
Callee-saved register
r4
Register arguments
r20
Callee-saved register
r5
Register arguments
r21
Callee-saved register
continued...
3. Programming Model
NII-PRG | 2018.04.18
Nios II Processor Reference Guide
45