Page 1 of 1

EE-GCC and EE-G++ caling conventions

Posted: Thu Jun 29, 2006 9:33 am
by Luzarius
I want to call c++ or c functions compiled with e-gcc or e-g++ from my assembly code but i am not sure how the compilers handle passing of arguments and return values.
Do they use the stack or registers $a0-$a3 and $v0-$v1 ?
a simple test program compiled with the -S assembly source option showed that it uses the registers but a few online message boards say GCC compilers use the stack.
Does this differ depending on how many arguments there are?
I'd be grateful for any information on this or a link to an article that covers this. thanks.

Re: EE-GCC and EE-G++ caling conventions

Posted: Thu Jun 29, 2006 9:39 am
by Drakonite
Luzarius wrote: Does this differ depending on how many arguments there are?
Yep. Specifically the first so many arguments are in registers, then if they are more they go on the stack.

Posted: Thu Jun 29, 2006 9:44 am
by Luzarius
Cool thanks. Also i should ask if these compilers follow the convention of not messing with registers $s0-$s7 or at least restoring them before returning to the caller.

Posted: Thu Jun 29, 2006 10:01 am
by Drakonite
Thats part of the MIPS ABI so I would assume it does ;)