One question: Does the omission of sign extension by avr-gcc remain
without optimisation for size?

Thank you for your suggestion, I did not think of that.

When I compile without any optimization at all, the sign extension
by the called function is also missing, like with optimizations
enabled.

A user on avrfreaks suggested that the paragraph in the AVR-Libc FAQ
that causes the confusion might simply be mixing up "called function"
and "calling function".


is:  Return values: 8-bit in r24 (not r25!), ... 8-bit return values
are zero/sign-extended to 16 bits by the  *called*  function

(which is actually contradicting itself, as mentioned by another user)


should be:  Return values: 8-bit in r24 (not r25!), ... 8-bit return
values are zero/sign-extended to 16 bits by the  *calling*  function


Also, the avr-gcc ABI page states that 8-bit values are returned in
r24 and does not say anything about 8-bit return values being extended
to 16 bits by the called function.  [1]

So I think that the "called" vs "calling" mixup might actually be the
answer to my question.


Benoit

[1]  https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention



_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to