Hello Philipp,

Monday, December 27, 2021, 12:12:08 PM, you wrote:

Oh, THANK YOU SO MUCH for clarification! So, __banked forces __sdcccall(0), 
that's nice.

I am starting with the GBDK-2020 library update now, so, i will write if i find 
some 
problems.


PKK> What SDCC currently does for z80 and related:

PKK> 1) __banked can be combined with either __sdcccall(0) or __sdcccall(1).
PKK> 2) Calls to  __sdcccall(0) or __sdcccall(1) __banked functions always pass 
all parameters on the stack.
PKK> 3) Calls to __banked __z88dk_fastcall function pass the only 8/16/32 bit 
parameter in registers.
PKK> 4) In calls to __banked functions, the stack is always cleaned up by the 
caller.
PKK> 5) The return values is passed as the caling convention (__sdcccall(0) or 
__sdcccall(1) pr __z88dk_fastcall or __smallc) specify.
PKK> 6) ___sdcc_bcall trampoline is used for "legacy banking" (i.e. when 
compiling with --legacy-banking).
PKK> 7) __sdcc_bcall_abc trampoline is used for __z88dk_fastcall __banked 
functions.
PKK> 8) __sdcc_bcall_ehl is used for all other __banked functions.
PKK> 9) Default trampolines are provided in the library, and could be 
overridden by the user.
PKK> 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.

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

PKK> 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.
PKK> 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.

PKK> Philipp

-- 
Best regards,
 Tony                            mailto:unt...@mail.ru



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

Reply via email to