Specifications

The equivalent structure representing the arguments is:
struct { int a; int b; };
The first 16 bytes of the struct are assigned to r4 through r7. Therefore r4 is assigned the value of a and
r5 the value of b.
The first 16 bytes to a function taking variable arguments are passed the same way as a function not taking
variable arguments. The called function must clean up the stack as necessary to support the variable
arguments.
Refer to Stack Frame for a Function with Variable Arguments
Related Information
Stack Frame for a Function with Variable Arguments on page 7-5
Return Values
Return values of types up to 8 bytes are returned in r2 and r3. For return values greater than 8 bytes, the
caller must allocate memory for the result and must pass the address of the result memory as a hidden
zero argument.
The hidden zero argument is best explained through an example.
Example 7-2: Returned struct
/* b() computes a structure-type result and returns it */
STRUCT b(int i, int j)
{
...
return result;
}
void a(...)
{
...
value = b(i, j);
}
In the example above, if the result type is no larger than 8 bytes, b() returns its result in r2 and r3.
If the return type is larger than 8 bytes, the Nios II C/C++ compiler treats this program as if a() had
passed a pointer to b(). The example below shows how the Nios II C/C++ compiler sees the code in the
Returned Struct example above.
Example 7-3: Returned struct is Larger than 8 Bytes
void b(STRUCT *p_result, int i, int j)
{
...
*p_result = result;
}
void a(...)
{
STRUCT value;
...
7-8
Return Values
NII51016
2015.04.02
Altera Corporation
Application Binary Interface
Send Feedback