ABI of gcc?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
junkoi
Member
Member
Posts: 63
Joined: Wed Jan 23, 2008 8:55 pm

ABI of gcc?

Post 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
2xpc
Posts: 3
Joined: Thu Apr 10, 2008 5:59 am

Post 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.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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.
2xpc
Posts: 3
Joined: Thu Apr 10, 2008 5:59 am

Post by 2xpc »

Ok I admit I assumed Junkoi wants to call some C function from assembly :?
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

2xpc wrote:Ok I admit I assumed Junkoi wants to call some C function from assembly :?
... from 32 bit x86 only.
Post Reply