MicroBlaze Processor Reference Guide
155
UG081 (v14.7)
Memory Model
Calling Convention
The caller function passes parameters to the callee function using either the registers
(R5 through R10) or on its own stack frame. The callee uses the stack area of the caller to store the
parameters passed to the callee.
. The parameters for Func 2 are stored either in the registers R5 through R10 or
on the stack frame allocated for Func 1.
If Func 2 has more than six integer parameters, the first six parameters can be passed in registers R5
through R10, whereas all subsequent parameters must be passed on the stack frame allocated for
Func 1, starting at offset SP + 28.
Memory Model
The memory model for MicroBlaze classifies the data into four different parts: Small Data Area,
Data Area, Common Un-Initialized Area, and Literals or Constants.
Small Data Area
Global initialized variables which are small in size are stored in this area. The threshold for deciding
the size of the variable to be stored in the small data area is set to 8 bytes in the MicroBlaze C
compiler (mb-gcc), but this can be changed by giving a command line option to the compiler.
Details about this option are discussed in the
GNU Compiler Tools
chapter. 64 kilobytes of memory
is allocated for the small data areas. The small data area is accessed using the read-write small data
area anchor (R13) and a 16-bit offset. Allocating small variables to this area reduces the requirement
of adding
IMM
instructions to the code for accessing global variables. Any variable in the small
data area can also be accessed using an absolute address.
Data Area
Comparatively large initialized variables are allocated to the data area, which can either be accessed
using the read-write SDA anchor R13 or using the absolute address, depending on the command line
option given to the compiler.
Common Un-Initialized Area
Un-initialized global variables are allocated in the common area and can be accessed either using the
absolute address or using the read-write small data area anchor R13.
Literals or Constants
Constants are placed into the read-only small data area and are accessed using the read-only small
data area anchor R2.
The compiler generates appropriate global pointers to act as base pointers. The actual values of the
SDA anchors are decided by the linker, in the final linking stages. For more information on the
various sections of the memory please refer to
MicroBlaze Linker Script Sections
in the
Embedded
System Tools Reference Manual
.The compiler generates appropriate sections, depending on the
command line options. Please refer to the
GNU Compiler Tools
chapter in the
Embedded System
Tools Reference Manual
for more information about these options.