68 www.xilinx.com MicroBlaze Processor Reference Guide
1-800-255-7778 UG081 (v6.0) June 1, 2006
Chapter 3: MicroBlaze Application Binary Interface
R
Consider an example where Func1 calls Func2, which in turn calls Func3. The stack
representation at different instances is depicted inFigure 3-2. After the call from Func 1 to
Func 2, the value of the stack pointer (SP) is decremented. This value of SP is again
decremented to accommodate the stack frame for Func3. On return from Func 3 the value
of the stack pointer is increased to its original value in the function, Func 2.
Details of how the stack is maintained are shown in Figure 3-2.
Figure 3-1: Stack Convention
High Address
Function Parameters for called sub-routine
(Arg n ..Arg1)
(Optional: Maximum number of arguments
required for any called procedure from the
current procedure.)
Old Stack Pointer Link Register (R15)
Callee Saved Register (R31....R19)
(Optional: Only those registers which are used
by the current procedure are saved)
Local Variables for Current Procedure
(Optional: Present onlyif Locals deļ¬ned in the
procedure)
Functional Parameters (Arg n .. Arg 1)
(Optional: Maximum number of arguments
required for any called procedure from the
current procedure)
New Stack
Pointer
Link Register
Low Address
X9584
High Memory
Low Memory
SP
Func 1
SP
Func 1
Func 2
SP
Func 1
Func 2
Func 3
SP
Func 1
Func 2