Page 1 of 1
ABI of gcc?
Posted: Thu Apr 10, 2008 11:36 pm
by junkoi
Hi,
Anybody knows where to get the ABI of gcc? I want to know which registers (x86) are reserved and clobbered when calling a C function.
Thanks,
J
Posted: Fri Apr 11, 2008 12:45 am
by 2xpc
Hi Junkoi,
Maybe the following url will help you. :
http://www.delorie.com/djgpp/doc/ug/asm/calling.html
Basically just push eax, ecx, and edx to save them, then push the function's arguments on the stack then 'call' the C function . GCC does NOT pop the function's arguments, it's up to you to pop them after the call.
2xpc.
Posted: Fri Apr 11, 2008 1:20 am
by JamesM
GCC implements this abi: registers $s0-$s7, $ra, $at are stored on the stack, all others are scratch... oh wait you were talking about the
cdecl ABI. That GCC happens to implement.
Posted: Fri Apr 11, 2008 3:24 am
by 2xpc
Ok I admit I assumed Junkoi wants to call some C function from assembly
Posted: Fri Apr 11, 2008 3:25 am
by JamesM
2xpc wrote:Ok I admit I assumed Junkoi wants to call some C function from assembly
... from 32 bit x86 only.