SPRAB89A September 2011 – March 2014
The first ten arguments to a function are passed in registers. Arguments are assigned, in declared order (except arguments passed in register quads), to registers in the following sequence:
A4, B4, A6, B6, A8, B8, A10, B10, A12, B12 |
Arguments whose size is between 32 and 64 bits are passed in register pairs, using the even registers from the previous list for their least-significant part and the corresponding odd register for their most-significant part. For example, in the following example 'a' is passed in A4 and 'b' in B5:B4:
func1(int a, double b);
Arguments of type float complex are passed in register pairs. The ordering is endian dependent. In little-endian mode the real part is passed in the even register and the imaginary part in the odd. For big-endian mode this ordering is reversed.
Arguments of type double complex are passed in register quads, using the first available quad from the following list: A7:A6:A5:A4, B7:B6:B5:B4, A11:A10:A9:A8, B11:B10:B9:B8. In little-endian mode the real part is passed in the lower-numbered pair (e.g. A5:A4) and the imaginary part is passed in the higher-numbered pair (A7:A6). For big-endian this ordering is reversed. Any register that is bypassed for a quad-register argument is available for subsequent arguments. For example, in the following function 'w' is passed in A4, 'x' is passed in B4, 'y' is passed in A11:A10:A9:A8, and 'z' backfills into A6:
func2(int w, int x, double complex y, int z);
Any remaining arguments are placed on the stack at increasing addresses, starting at SP+4. Each argument is placed at the next available address correctly aligned for its type. Thus if the first stack argument requires 64-bit alignment, its address will be SP+8.
In C++, the this pointer is passed to non-static member functions in A4 as an implicit first argument.
Structures and unions with size 64 bits or less are passed by value, either in registers or on the stack as described in the list that follows. Structures and unions larger than 64 bits are passed by reference, as described in Section 3.6.
Any arguments not passed in registers are placed on the stack at increasing addresses, starting at SP+4. Each argument is placed at the next available address correctly aligned for its type, subject to the following additional considerations:
Note that SP+4 is not 8-byte aligned, so if the first argument requires 8 byte alignment, it will be stored in memory at SP+8.
For a variadic C function (that is, a function declared with an ellipsis indicating that it is called with varying numbers of arguments), the last explicitly declared argument and all remaining arguments are passed on the stack, so that its stack address can act as a reference for accessing the undeclared arguments.
Undeclared scalar arguments to a variadic function that are smaller than int are promoted to and passed as int, in accordance with the C language.