Inc. Typewriter User Manual

MicroBlaze Processor Reference Guide www.xilinx.com 69
UG081 (v6.0) June 1, 2006 1-800-255-7778
Memory Model
R
Figure 3-2: Stack Frame
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 caller’s stack area to store the
parameters passed to the callee.
Refer toFigure 3-2. The parameters forFunc 2 are stored either inthe registers R5through
R10 or on the stack frame allocated for Func 1.
Memory Model
The memory model for MicroBlaze classifies the data into four different parts:
Small data area
Globalinitialized variables which aresmallin size arestoredin thisarea.Thethresholdfor
deciding the size of the variable to be stored in the small data area is set to 8 bytes in the
MicroBlazeC compiler (mb-gcc), but thiscanbechangedby giving a command lineoption
to the compiler. Details about this option are discussed in the GNU Compiler Tools chapter.
64K bytes 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
Comparativelylargeinitialized variables areallocatedtothedata area,whichcaneither 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-initializedglobalvariablesareallocated in the common areaandcanbeaccessedeither
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 the Address Management
chapter. The compiler generates appropriate sections, depending on the command line
options. Please refer to the GNU Compiler Tools chapter for more information about these
options.