Menu

#949 User-specified z80 calling convention (register parameters)

None
open
nobody
None
5
2025-12-19
2024-10-30
No

It would be useful to allow the user to specify the calling convention for z80-related ports on a per-function basis. Not just choosing one known to SDCC (as is possible now using the __sdcccall, __z88dk_fastcall, etc keywords), but actually allow the user to specify which register which parameter is to be passed in. The use-case would be directly interfacing with assembler code that cannot be changed (i.e. BIOSes), to avoid the need for hand-written asm wrapper functions.
For the user interface, C2X attributes would be used, which means we need further work on [feature-requests:#654] first.

This was previously discussed as part of [feature-requests:#253], but IMO it makes more sense to have a separate ticket for it.

Related

Feature Requests: #253
Feature Requests: #654

Discussion

  • Philipp Klaus Krause

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
     It would be useful to allow the user to specify the calling convention for z80-related ports on a per-function basis. Not just choosing one known to SDCC (as is possible now using the `__sdcccall`, `__z88dk_fastcall`, etc keywords), but actually allow the user to specify which register which parameter is to be passed in. The use-case would be directly interfacing with assembler code that cannot be changed (i.e. BIOSes), to avoid the need for hand-written asm wrapper functions.
    -For the user interface, C2X attributes could be used.
    +For the user interface, C2X attributes would be used, which means we need further work on [feature-requests:#654] first.
    
     This was previously discussed as part of [feature-requests:#253], but IMO it makes more sense to have a separate ticket for it.
    
    • Group: -->
     

    Related

    Feature Requests: #253
    Feature Requests: #654

  • Aoineko

    Aoineko - 2024-10-30

    If I understand C2X attribute correctly, for Z80 it should look like something like:

    void Func1(char [[sdcc::reg(C)]] var1, char [[sdcc::reg(A)]] var2);
    
    short [[sdcc::reg(DE)]] Func2(short [[sdcc::reg(HL)]] var1);
    
    char [[sdcc::reg(E)]] Func3(char [[sdcc::reg(A)]] var8, short [[sdcc::reg(IY)]] var16, long [[sdcc::reg(HL:DE)]] var32);
    

    Is that right?

     

    Last edit: Aoineko 2024-10-30
  • Ragozini Arturo

    Ragozini Arturo - 2025-12-14

    This could improve a lot the efficiency of the z80 code during parameter exchange with existing routines

     
    👍
    1

Log in to post a comment.