Figure 15.
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
7.4.3.3. 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 150
7.4.4. 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.
7. Application Binary Interface
NII-PRG | 2018.04.18
Nios II Processor Reference Guide
151