Contents|Index|Previous|Next

Calling conventions for Hitachi SH

The Hitachi SH passes the first four words of arguments in registers R4 through R7. All remaining arguments are pushed onto the stack, last to first, so that the lowest numbered argument not passed in a register is at the lowest address in the stack. The registers are always filled, so a double word argument starting in R7 would have the most significant word in R7 and the least significant word on the stack.

Function return values are stored in R0. Register R15 has a reserved use. Registers R0 through R7, T, MACH and MACL can be used for temporary values.

When a function is compiled with the default options, it must return with registers R8 through R1 unchanged.

The switch, -mhitachi SH, makes the MACH and MACL registers caller-saved, for compatibility with the Hitachi SH tool chain at the expense of performance.

Note:
Functions compiled with different calling conventions cannot be run together without some care.