Altera_Forum
Honored Contributor
20 years agoVariable arguments allocation
Dear everybody,
I need to get variable arguments from a function without using va_args. ABI rules for Nios II state that a copy of r4 thru r7 is saved on the stack after the function call in order to use va_args. Now, I make the following call: MyFunction (param1, param2) (the prototype of MyFunction is void MyFunction (char *, ...). Well, the code written by the compiler as the prolog of MyFunction is: addi sp,sp,-32 stw ra,16(sp) stw fp,12(sp) mov fp,sp stw r5,20(fp) stw r6,24(fp) stw r7,28(fp) stw r4,0(fp) MyFunction uses two "int" local variables. What is really strange for me is that r4 and r5 (my arguments) are copied at 0(fp) and 20(fp). I expect that r5 is copied at 4(fp). Are you able to explain me this compiler behaviour ? Best Regards /Alessandro