Hello Philipp, Thursday, December 30, 2021, 4:31:50 PM, you wrote:
>> > Thursday, December 30, 2021, 2:44:26 PM, you wrote: >> > Oh, i see! Missed that. Thank you again. >> > PKK> On 30.12.21 12:41, Tony Pavlov via Sdcc-user wrote: >>>> So, __banked forces __sdcccall(0), that's nice. >> > PKK> For parameters, and caller vs. callee cleanup, essentially yes. But >> > not for the return value. >> > > PKK> Stated with different words: PKK> Calls to __banked functions are handled like calls to functions with variable arguments. There is a problem with returning uint8_t results from __banked functions. By the new convention it is returned in A, but the tail code of the trampoline function is very likely spoil A, while having result in E, DE, DEHL is perfect here. the new trampoline looks like this: ___sdcc_bcall_ehl:: ; Performs a long call. ldh a, (__current_bank) push af ; Push the current bank onto the stack ld a, e ldh (__current_bank), a ld (.MBC_ROM_PAGE), a ; Perform the switch rst 0x20 ; call HL pop bc ; Pop the old bank ld c, a ld a, b ldh (__current_bank), a ld (.MBC_ROM_PAGE), a ld a, c ret while the old one was: ___sdcc_bcall_ehl:: ; Performs a long call. ldh a, (__current_bank) push af ; Push the current bank onto the stack ld a, e ldh (__current_bank), a ld (.MBC_ROM_PAGE), a ; Perform the switch rst 0x20 ; call HL pop af ; Pop the old bank ldh (__current_bank), a ld (.MBC_ROM_PAGE), a ret which is shorter and faster. __banked already force to pass parameters on stack. why not simply imply __sdcccall(0) for __banked? look at the trampoline from the native SDCC Z80 library: ___sdcc_bcall_ehl:: call get_bank push af inc sp call ___sdcc_bjump_ehl dec sp pop bc push af ld a, b call set_bank pop af ret push af/pop af plus loads, what for? another annoying thing is one byte hidden parameter for the bank number on the Z80 target. inc sp/dec sp everywhere, while on gbz80 two bytes are reserved - that is much faster! why not unify that? also, on systems like MSX you may want to save/restore more than one page and two bytes may be very useful here! -- Best regards, Tony mailto:unt...@mail.ru _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user