154
MicroBlaze Processor Reference Guide
UG081 (v14.7)
Chapter 4:
MicroBlaze Application Binary Interface
Table 4-3:
Stack Convention
Consider an example where Func1 calls Func2, which in turn calls Func3. The stack representation
at different instances is depicted in
. 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
.
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 only if Locals defined 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
X-Ref Target - Figure 4-1
Figure 4-1:
Stack Frame
High Memory
Low Memory
SP
SP
SP
SP
Func 1
Func 1
Func 1
Func 1
Func 2
Func 2
Func 2
Func 3