Stack Convention - Xilinx MicroBlaze Reference Manual

32-bit soft processor
Hide thumbs Also See for MicroBlaze:
Table of Contents

Advertisement

Stack Convention

The stack conventions used by MicroBlaze are detailed in
The shaded area in
the unshaded area indicates the callee frame function. The ABI conventions of the stack
frame define the protocol for passing parameters, preserving non-volatile register values,
and allocating space for the local variables in a function.
Functions that contain calls to other subroutines are called as non-leaf functions. These
non-leaf functions have to create a new stack frame area for its own use. When the program
starts executing, the stack pointer has the maximum value. As functions are called, the stack
pointer is decremented by the number of words required by every function for its stack
frame. The stack pointer of a caller function always has a higher value as compared to the
callee function.
Table 4-3: Stack Convention
High Address
Old Stack
Pointer
New Stack
Pointer
Low Address
Consider an example where Func1 calls Func2, which in turn calls Func3. The stack
representation at different instances is depicted in
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
MicroBlaze Processor Reference Guide
UG984 (v2016.2) June 8, 2016
UG984 (v2016.1) April 6, 2016
Table 4-3
denotes a part of the stack frame for a caller function, while
Function Parameters for called sub-routine (Arg n .. Arg1)
(Optional: Maximum number of arguments required for any
called procedure from the current procedure).
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)
Link Register
www.xilinx.com
Chapter 4: MicroBlaze Application Binary Interface
Table
4-3.
Figure
4-1. After the call from Func 1 to
Figure
4-1.
172
Send Feedback

Advertisement

Table of Contents
loading

Table of Contents