I want to implement function calls and returning of values in the stm8 branch sometime soon. For this a calling convention is necessary.
Now, other compilers (IAR, Raisonance) do the following: structs, unions, and types of size more than 32 bit: Pass on stack. 8-bit return value: Pass in A. 16-bit return value: Pass in X. For 24-bit and 32-bit values these compilers use pseudo-registers in memory (similar to the hc08 port). I do not intend to use pseudo-registers in the stm8 port, and as far as I see, the other compilers for stm8 do not agree on how to use pseudo-registers for returning 24-bit and 32-bit values. Basically, we have the choice of using the stack to return 24-bit and 32-bit return values, or use the register Y. We need t decide on how to pass parameters as well, but here I suggest a temporary solution: Just pass everything on stack. This is less efficient than passing some parameters in registers, but the code for passing parameters on the stack needs to be written anyway (since as soon as a function has more than a few bytes of on-stack parameters we'll need it), and we can always change it later (the only problem would be sdcc users writing a large amount of asm code to this calling convention that then would have to be changed later). A related question is which registers should be caller-save and which should be callee-save. In general, making a register caller-save is a bit better for code speed, while making a register callee-save is a bit better for code size. Registers used to pass information between callee and caller must be caller-save. So I suggest making A and X caller-save. I'm not sure about Y. Philipp ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user