The same calling convention is used for a fixed as well as a variable number of arguments:
or, alternatively, on the stack, if the size of the argument is greater than 4 bytes or there is no register left.
The actual passing order is from right to left (that is, the first argument pushed is the rightmost one).
The following example demonstrates argument passing for a simple function with a fixed number of arguments:
void func(char a, char b, int c, long d, long e) { g1 = a; g2 = b; g3 = c; g4 = d; g5 = e; } ... void main(void) { ... func(0x12, 0x34, 0x5678, 0x1234ABCD, 0x5678ABCD); ... }
Assuming inlining has been turned off, the compiler generates code as listed below:
29: func(0x12, 0x34, 0x5678, 0x1234ABCD, 0x5678ABCD); LD D6,#1450748877 PSH D6 LD D0,#52 PSH D0 LD D6,#305441741 LD D2,#22136 LD D0,#18 JSR func