SDCC calling convention

From Fox Labs Wiki
Jump to navigation Jump to search

By default, SDCC uses the stack to provide parameters to function calls, and uses the L. HL or DE - HL registers for return values depending on the size of the return value. SDCC starting in version 4.2.0 introduced changes to the calling conventions used.

__sdcccall(0) __sdcccall(1) __z88dk_fastcall
Return
8 bits L A L
16 bits HL HL HL
32 bits DE - HL HL - DE DE - HL
Parameters
8 bits Stack A L
16 bits Stack HL HL
32 bits Stack HL - DE HL - DE
8 + 8 bits Stack A + L Invalid
8 + 16 bits Stack A + DE Invalid
16 + 16 bits Stack HL + DE Invalid
16 + 8 bits Stack HL + Stack Invalid