Specifications

Figure 7-3: Stack Frame Using Variable Arguments
In function a()
Just prior to calling b()
In function b()
Just after executing prologue
Incoming
stack
arguments
Other saved
registers
Space for
outgoing
stack
arguments
Allocated and freed by a()
(i.e. the calling function)
Allocated and freed by b()
(i.e. the current function)
Outgoing
stack
arguments
Higher addresses
Lower addresses
Stack pointer
Copy of r7
Copy of r6
Copy of r5
Copy of r4
Space for
stack
temporaries
Stack pointer
Return address
Saved frame
pointer
Frame pointer
Stack Frame for a Function with Structures Passed By Value
Functions that take struct value arguments still have their first 16 bytes of arguments arriving in registers
r4 through r7, just like other functions.
If part of a structure is passed using registers, the function might need to copy the register contents back
to the stack. This operation is similar to that required in the variable arguments case as shown in the
figure above, Stack Frame Using Variable Arguments.
Related Information
Stack Frame for a Function with Variable Arguments on page 7-5
Function Prologues
The Nios II C/C++ compiler generates function prologues that allocate the stack frame of a function for
storage of stack temporaries and outgoing arguments. In addition, each prologue is responsible for saving
the state of the calling function. This entails saving certain registers on the stack. These registers, the
callee-saved registers, are listed in Nios II ABI Register Usage Table in the Register Usage section. A
function prologue is required to save a callee-saved register only if the function uses the register.
Given the function prologue algorithm, when doing a back trace, a debugger can disassemble instructions
and reconstruct the processor state of the calling function.
7-6
Stack Frame for a Function with Structures Passed By Value
NII51016
2015.04.02
Altera Corporation
Application Binary Interface
Send Feedback