[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] avr-gcc ABI: return 8-bit value from function
From: |
Benoit Steinmetz |
Subject: |
Re: [avr-gcc-list] avr-gcc ABI: return 8-bit value from function |
Date: |
Wed, 06 Jun 2018 23:16:35 +0200 |
User-agent: |
Horde Application Framework 5 |
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