Hi Oliver, On Fri, Feb 11, 2011 at 05:54:22PM +0100, Oliver Schmidt wrote: > Hi Gábor, > > >> Assembler funcions with 8-bit return value need to zero the X register on exit. > > > [...] if I have - let's say - $20 in X and in A > > too on exit, what the "C code will think", return value is $2020? It's quite > > strange, since the return value of the prototype is "char", so for unsigned > > it cannot be more than $FF. [...] > > As far as I know it isn't important as long as you i.e. directly > assign the return value to an 8-bit variable. If you however use the > return value in an expression then according to the type promotion > rules all values in the expression are promoted to an 16-bit value. > The compiler makes the presumtion that the promotion of function > return values is a nop - and this presumption breaks with assembler > functions returning arbitrary values in X... Ahaaa ... Interesting. For sure, I now that promoted stuff, but I always imagined that unsigned char as a byte return value is always a byte, if it's needed to promoted to an 16 bit value, X can be loaded with 0 there (if X holds the high byte of the value), I haven't known that it's already assumed that a function return with 16 bit value in same way (I mean: high byte is zero) even if the return type is only 8 bit. Thanks for the explanation! > > That's at least what I made up myself - we'll see how much of it is > left when Uz tells the truth ;-) :) :) ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Fri Feb 11 22:06:31 2011
This archive was generated by hypermail 2.1.8 : 2011-02-11 22:06:34 CET