GBDK libraries documentation
PrevChapter 4. Assembly languageNext

Calling convention

lcc in common with almost all C compilers prepends a '_' to any function names. For example the function printf(...) begins at the label _printf::. Note that all functions are declared global.

The parameters to a function are pushed in right to left order with no aligning - so a byte takes up a byte on the stack instead of the more natural word. So for example the function int store_byte( UWORD addr, UBYTE byte) would push 'byte' onto the stack first then addr using a total of three bytes. As the return address is also pushed, the stack would contain:

Note that the arguments that are pushed first are highest in the stack due to how the GB's stack grows downwards.

The function returns in DE. I'm not sure how a FP number is returned.


PrevHomeNext
Assembly languageUpVariables and registers