why not just try it?
unsigned int fun ( unsigned int, unsigned int, unsigned int, unsigned int, unsigned int ); unsigned int myfun ( void ) { return(fun(1,2,3,4,5)); }
assemble and then disassemble
> arm-none-eabi-gcc -O2 -c fun.c -o fun.o > arm-none-eabi-objdump -D fun.o
assembly output contains
00000000 <myfun>: 0: e52de004 push {lr} ; (str lr, [sp, #-4]!) 4: e3a03005 mov r3, #5 8: e24dd00c sub sp, sp, #12 c: e58d3000 str r3, [sp] 10: e3a01002 mov r1, #2 14: e3a02003 mov r2, #3 18: e3a03004 mov r3, #4 1c: e3a00001 mov r0, #1 20: ebfffffe bl 0 <fun> 24: e28dd00c add sp, sp, #12 28: e49de004 pop {lr} ; (ldr lr, [sp], #4) 2c: e12fff1e bx lr
the first four operands are in the register r0-r3, as expected. the fifth operand, however, is pushed onto the stack. why the compiler allocates 12 bytes instead of 4 for the operand, which is a mystery ... Perhaps viewing the function makes sense:
unsigned int fun ( unsigned int a, unsigned int b, unsigned int c, unsigned int d, unsigned int e ) { return(a+b+c+de); }
assemble and disassemble
arm-none-eabi-gcc -O2 -c fun.c -o fun.o arm-none-eabi-objdump -D fun.o 00000000 <fun>: 0: e0811000 add r1, r1, r0 4: e0812002 add r2, r1, r2 8: e59d0000 ldr r0, [sp] c: e0823003 add r3, r2, r3 10: e0600003 rsb r0, r0, r3 14: e12fff1e bx lr
therefore, the caller simply knows that the operand is the first thing on the stack and does not care about the stack frame created by the caller. so itโs a mystery why in this case the caller allocated 12 bytes instead of 4.
arm-none-eabi-gcc --version arm-none-eabi-gcc (GCC) 4.7.2 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
seeing that the compiler actually implements the calling convention can make reading the calling convention more understandable. Or, if you create such examples for a specific function prototype that interests you in the compiler that you are interested in, you do not need to read the agreement, you just make your caller or called party depending on what interests you, in accordance with what the compiler does for itself.