I am in favor of adding a cli option to enable the old calling method.

This change can break nearly every naked member we have if I understand
correctly, and without clear notice we may be compiling code for the old
convention, which will just cause huge headaches.

Which convention used is not important to me, but I wonder what the cause
for the change is. Is it faster somehow?


On Fri, Jul 30, 2021, 3:35 PM Philipp Klaus Krause <p...@spth.de> wrote:

> Am 30.07.21 um 15:12 schrieb a...@etchedpixels.co.uk:
> > On Tue, 27 Jul 2021 23:15:32 +0200
> > Philipp Klaus Krause <p...@spth.de> wrote:
> >
> >> A new calling convention for z80ยน has been implemented in the
> >> breaktheworld branch:
> >> https://sourceforge.net/p/sdcc/code/HEAD/tree/branches/breaktheworld/
> >>
> >> Anyone wanting to test it or experiment with it is welcome to use the
> >> branch.
>
> I don't think there will be big changes to what is implemented in the
> branch, but I can't fully rule them out either - especially wrt. stack
> cleanup for funtions returning float. Also, if many SDCC users dislike
> the proposed changes, there is still the possibility of not changing the
> convention at all.
>
> > It would be useful if you described the change as it's a bit hard to
> > assess a new ABI without explanation.
>
> There is documentation in the manual in that branch, but here are the
> changes (for z80, z180, z80n - other ports are likely to use something
> else):
>
> * Return values:
>  - Old: l for 8 bit, hl for 16 bit, dehl for 32 bit
>  - New: a for 8 bit, de for 16 bit, hlde for 32 bit
> * Parameters:
>  - Old: Always all on stack
>  - New: All on stack for functions with variable arguments, otherwise:
>     - First parameter in a if 8 bit, hl if 16 bit, hlde if 32 bit.
>     - If first parameter is in a, and second has 8 bits, it is in l
>     - If first parameter is in a or hl, and the second has 16 bits,
>       it is in de
>     - Other parameters on the stack
> * Stack cleanup:
>  - Always done by caller
>  - New: Done by caller with the following exceptions:
>     - Functions that return at most 16 bits (e.g. void, char, int) and
>       do not have variable arguments
>     - Functions that return float and
>       have a first parameter of type float and
>       do not have variable arguments
>
> > Also can we please have defines
> > from the compiler for ABI breakage so that code can do
> >
> > #if (__SDCC_Z80_ABI == 2)
> > #define asmcall   xxx
> > #else
> > #define asmcall yyy
> > #endif
>
> The original plan was to just use the version number. But since it now
> has become clear that some users would not want the change, if we still
> change the default, we'd need such a define to go along with a
> --stdccoldcall command-line option to restore the old default behaviour.
>
> Philipp
>
>
> _______________________________________________
> Sdcc-user mailing list
> Sdcc-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sdcc-user
>
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to