Am 12.01.24 um 19:39 schrieb Basil Hussain:
Can I get some quick clarification/confirmation of the PDK calling
convention? It's not documented in the SDCC manual.
Arguments:
- First/only 8-bit argument passed in A?
- Multi-byte arguments are passed in overlay memory. To reference in
inline assembly, they are assigned names of "_<func_name>_PARM_<n>",
where n is the 1-based left-to-right argument index.
Currently, the calling convention does not pass arguments in registers.
They are either passed at those names you mentioned, or on the stack.
The latter is done for __reentrant functions and when --stack-auto is
used. When arguments of that have an odd number n of bytes are passed on
the stack, they are passed as n+1 bytes, with an unspecified value in
the topmost byte.
Return values:
- 8-bit return values are in A.
- 16-bit return value has MSB in P, LSB in A. (Why not just both in P?)
- 32-bit return value - ???
struct, union and any return values larger than 16 bits are returned
using an extra hidden pointer parameter, that points to the location, to
which the result is written.
Otherwise: 8-bit values in A, 16-bit values in PA.
P is an 8-bit pseudoregister, and the byte following P is always 0x00.
Both A and P are expected to be clobbered by the callee, and saved by
the caller?
Yes.
Functions always return using 'ret' instruction? That is, no 'goto'
shenanigans?
Tail call optimization can use goto.
Are there any differences between PDK13, 14, 15?
No.
Philipp
P.S.: The helper functions for pointer reads and writes are special, and
do not need to adhere to this calling convention.
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user