This section contains some examples of the calling convention in use.

Example #1

Consider the function prototype:

void fun1(int u, int v)

Reading from left to right, the parameter u is passed in register A[7] and v is passed in A[6]. The scratch registers A[4] and A[5] are not used to pass parameters and can be used in fun1 without needing to be preserved.

Example #2

Consider the function prototype:

void fun1(int u, long v, int w)

The parameter u is passed in register A[7]. Because v requires two registers to hold its value it is passed in the register pair A[6]:A[5] with A[6] holding the high part of v and A[5] the low part. The final parameter w is passed in A[4].

Example #2

Consider the function prototype:

void fun1(int u, long v, int w, int x)

The parameter u is passed in register A[7]. Because v requires two registers to hold its value, it is passed in the register pair A[6]:A[5] with A[6] holding the high part of v and A[5] the low part. Parameter w is passed in A[4]. As all scratch registers are now used, x is placed onto the software stack.

Example #3

Consider the function prototype:

void fun1(int u, long v, long w)

The parameter u is passed in register A[7]. Because v requires two registers to hold its value it is passed in the register pair A[6]:A[5] with A[6] holding the high part of v and A[5] the low part. When considering w, there is only one free scratch register left, which is A[4]. The compiler cannot fit w into a single register and therefore places the argument onto the software stack—the compiler does not split the value into two and pass half in a register and half on the software stack.

Example #4

Consider the function prototype:

void fun1(int u, long v, long w, int x, int y)

The parameter u is passed in register A[7]. Because v requires two registers to hold its value it is passed in the register pair A[6]:A[5] with A[6] holding the high part of v and A[5] the low part. When considering w, there is only one free scratch register left, which is A[4]. The compiler cannot fit w into the single register A[4] and therefore places the argument onto the software stack. When considering x, the compiler sees that A[4] is unused and so passes x in A[4]. All scratch registers are used when considering y, so the argument is placed onto the software stack. The parameters w and x are pushed onto the stack before the call and are pushed in reverse order, with y pushed before w.

This example shows two parameters, w and y, that are passed to the called routine on the stack, but they are separated by a parameter x that is passed in a register.