R

Chapter 3: MicroBlaze Application Binary Interface

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 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

Link Register

Pointer

 

 

 

Low Address

 

 

 

Consider an example where Func1 calls Func2, which in turn calls Func3. The stack representation at different instances is depicted in Figure 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.

High Memory

SP

Low Memory

Func 1

SP

Func 1

Func 2

SP

Func 1

Func 2

Func 3

SP

Func 1

Func 2

X9584

68

www.xilinx.com

MicroBlaze Processor Reference Guide

 

1-800-255-7778

UG081 (v6.0) June 1, 2006

Page 68
Image 68
Xilinx EDK 8.2i manual High Memory Low Memory Func