Stacks - Altera Nios II User Manual

Hide thumbs Also See for Nios II:
Table of Contents

Advertisement

Chapter 7: Application Binary Interface

Stacks

Table 7–2. Nios II ABI Register Usage (Part 2 of 2)
Register
r31
Notes to
(1) A function can use one of these registers if it saves it first. The function must restore the register's original value
(2) In the GNU Linux operating system, r22 points to the global offset table (GOT). Otherwise, it is available as a
(3) In the GNU Linux operating system, r23 is used as the thread pointer. Otherwise, it is available as a callee-saved
(4) If the frame pointer is not used, the register is available as a callee-saved temporary register. Refer to
The endianness of values greater than 8 bits is little endian. The upper 8 bits of a value
are stored at the higher byte address.
Stacks
The stack grows downward (i.e. towards lower addresses). The stack pointer points to
the last used slot. The frame pointer points to the saved frame pointer near the top of
the stack frame.
Figure 7–1
a() calls function b(), and the stack is shown before the call and after the prologue in
the called function has completed.
Figure 7–1. Stack Pointer, Frame Pointer and the Current Frame
Higher addresses
Stack pointer
Lower addresses
Each section of the current frame is aligned to a 32-bit boundary. The ABI requires the
stack pointer be 32-bit aligned at all times.
February 2014 Altera Corporation
Used by
Name
Compiler
v
ra
Table
7–2:
before exiting.
callee-saved general-purpose register.
general-purpose register.
Pointer Elimination" on page
7–4.
shows an example of the structure of a current frame. In this case, function
In function a()
Just prior to calling b()
Outgoing
stack
arguments
Frame pointer
Stack pointer
Callee
Saved
(1)
Return address
In function b()
Just after executing prologue
Incoming
Allocated and freed by a()
stack
(i.e. the calling function)
arguments
Return address
Saved frame
pointer
Other saved
registers
Space for
stack
Allocated and freed by b()
temporaries
(i.e. the current function)
Space for
outgoing
stack
arguments
Normal Usage
"Frame
Nios II Processor Reference Handbook
7–3

Advertisement

Table of Contents
loading

Table of Contents