What is the motivation and benefits for changing the calling convention? I was sure I remembered you posting before sometime on one of the mailing lists about changing the STM8 calling convention with some reasons, but I can't find anything now.

Personally, my comments are that I think the proposed new calling convention will make life difficult when writing assembly code that is to be called by C code. In my opinion, the current STM8 calling convention suits that scenario just fine.

Currently, where all arguments are on the stack, this gives more flexibility to use A/X/Y registers however one wants, and the function arguments are always there when you need them, without worrying about overwriting or preserving them. With the new convention, one typically would have to push A/X onto the stack immediately, and then use the values from there. If the aim is to reduce stack usage, then it would seem to be counter-productive in this respect.

I can see a little benefit of having the first 8/16-bit argument passed in A/X, as you may want to immediately operate on the argument value anyway (a lot of my assembly immediately does "ld a, (3,sp)" or "ldw x, (3,sp)" - you'd save that operation), but it's troublesome in that if you want to refer again to the argument value later, you would have needed to have saved it yourself. Any benefit will probably only be for the most trivial of single-argument functions.

SDCC 4.1.0 will likely use a different calling convention from the
current one for stm8.

Did you mean 4.2.0? Obviously, 4.1.0 is already out. :)

This aspect is similar to Raisonance, and to some degree IAR.

Is this a goal, to have some kind of binary compatibility with those compilers?

For the medium memory model, stack cleanup for stack parameters is
done by the calle for some cases

Typo obscures understanding here: is that supposed to be "caller" or "callee"?

Regards,
Basil Hussain


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

Reply via email to