On 19.11.21 16:09, Tony Pavlov via Sdcc-user wrote:
Hello!

the new __sdcccall(1) calling convention uses registers to pass
parameters into callee, but banked call trampolines may clobber
some registers, also far pointer address is being passed into
the trampoline in registers. how those work together?

what are the exact rules for passing parameters and also
requirements for the trampolines?

in z80 port there is also a variety of trampolines, how they
are being chosed?

should not __banked attribute force __sdcccall(1), for example?


What SDCC currently does for z80 and related:

1) __banked can be combined with either __sdcccall(0) or __sdcccall(1).
2) Calls to __sdcccall(0) or __sdcccall(1) __banked functions always pass all parameters on the stack. 3) Calls to __banked __z88dk_fastcall function pass the only 8/16/32 bit parameter in registers. 4) In calls to __banked functions, the stack is always cleaned up by the caller. 5) The return values is passed as the caling convention (__sdcccall(0) or __sdcccall(1) pr __z88dk_fastcall or __smallc) specify. 6) ___sdcc_bcall trampoline is used for "legacy banking" (i.e. when compiling with --legacy-banking). 7) __sdcc_bcall_abc trampoline is used for __z88dk_fastcall __banked functions.
8) __sdcc_bcall_ehl is used for all other __banked functions.
9) Default trampolines are provided in the library, and could be overridden by the user. 10) The default trampolines call user-specified helper functions set_bank and get_bank that get / set the bank in register a, but leave other registers unchanged.

Most of this should work ok, but there are two bugs:

a) The combination of 5) and 8) is a problem: The __sdcc_bcall_ehl assumes that a is not used for the return value, which results in a bug when that is not true (__sdcccall(1) returns 8-bit values in a). I've opened bug report #3298 for this. b) All this is apparently not documented in the manual (looks like the manual only documents how __banked works on mcs51 / ds390). I've opened bug report #3299 for this.

Philipp


_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to