gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

ASM > Calling Conventions

#19033 - f(DarkAngel) - Sat Apr 10, 2004 1:55 pm

Is there an online doc about calling conventions of ARM? Through disassembling C code, i've found that unlike usual x86, parameters are passed via registers instead of pushing to the stack.
One other question is, what is going to be done when compiler runs out of "free-to-modify" registers (r0-r12)? (like a function with 20 parameters) Pushing to the stack?

Finally, in x86, calling conventions are same for C and C++ (except for the label naming mang., which is solved with extern "C"). Is there a difference between C & C++ for GBA?
_________________
death scream...

#19040 - Cearn - Sat Apr 10, 2004 3:29 pm

You mean something like this?
For the second question, DekuTree64 and batblaster have answered it in this thread.
Lastly, when I started GBA programming I used C++ but switched to normal C lateron. Hardly had to change a thing when I did that (except the file extension and converting the inline functions to macros, it seems GCC doesn't like the inline keyword in .c files), so I guess the calling convention is the same.

#19147 - SmileyDude - Mon Apr 12, 2004 12:09 am

Cearn wrote:
Lastly, when I started GBA programming I used C++ but switched to normal C lateron. Hardly had to change a thing when I did that (except the file extension and converting the inline functions to macros, it seems GCC doesn't like the inline keyword in .c files), so I guess the calling convention is the same.


If you pass "-std=c99" on the command line to gcc, you can use inline functions again. I've switched all of my C code over to C99, and I haven't had any problems yet. In addition to inline, you get to declare variables in for loops (i.e, for(int i = 0; ...), the ability to declare variables anywhere in a functions (similar to C++ and Java), C++ style comments for real (as opposed to gcc just letting them slide even though the old standard didn't allow it), and a bunch more that I can't remember right now. Do a google search on C99 to find out more.
_________________
dennis