Xilinx EDK 8.2i manual Stack Convention

Models: EDK 8.2i

1 148
Download 148 pages 28.91 Kb
Page 67
Image 67

Stack Convention

R

Certain registers are used as dedicated registers and programmers are not expected to use them for any other purpose.

Registers R14 through R17 are used for storing the return address from interrupts, sub-routines, traps, and exceptions in that order. Sub-routines are called using the branch and link instruction, which saves the current Program Counter (PC) onto register R15.

Small data area pointers are used for accessing certain memory locations with 16 bit immediate value. These areas are discussed in the memory model section of this document. The read only small data area (SDA) anchor R2 (Read-Only) is used to access the constants such as literals. The other SDA anchor R13 (Read- Write) is used for accessing the values in the small data read-write section.

Register R1 stores the value of the stack pointer and is updated on entry and exit from functions.

Register R18 is used as a temporary register for assembler operations.

MicroBlaze includes special purpose registers such as: program counter (rpc), machine status register (rmsr), exception status register (resr), exception address register (rear), and floating point status register (rfsr). These registers are not mapped directly to the register file and hence the usage of these registers is different from the general purpose registers. The value of a special purpose registers can be transferred to a general purpose register by using mts and mfs instructions (For more details refer to the “MicroBlaze Application Binary Interface” chapter).

Stack Convention

The stack conventions used by MicroBlaze are detailed in Figure 3-1

The shaded area in Figure 3-1denotes a part of the caller function’s stack frame, while the unshaded area indicates the callee function’s frame. 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 which contain calls to other sub-routines 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 will have 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 will always have a higher value as compared to the callee function.

MicroBlaze Processor Reference Guide

www.xilinx.com

67

UG081 (v6.0) June 1, 2006

1-800-255-7778

 

Page 67
Image 67
Xilinx EDK 8.2i manual Stack Convention