[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-libc-dev] [bugs #10450] missing __volatile__ in CRC functions c
From: |
Dmitry K. |
Subject: |
Re: [avr-libc-dev] [bugs #10450] missing __volatile__ in CRC functions core |
Date: |
Sat, 20 Nov 2004 16:11:16 +1000 |
User-agent: |
KMail/1.5 |
At 20 Sep 2004 Yann GOUY wrote:
> http://savannah.nongnu.org/bugs/?func=detailitem&item_id=10450
> Original Submission: in <avr/crc16.h>, the cores of the CRC functions use
> inline assembly language.
> the "keyword" __asm__ shall be followed by __volatile__ else compiling those
> functions with "-Os -mcall-prologues" completly suppress the assembly
> intructions.
There is no mistake. The code is suppressed, if its result (or by-effects) is
not used further. See old discussion about program memory reading macros.
For example:
~~~~~~~~~~~
#include <avr/crc16.h> /* without `__volatile__' */
int foo (void)
{
char s[10], *p;
int sum, i;
/* Filling s[] is omited. */
sum = 0;
p = s;
for (i = sizeof(s); i; --i)
sum = _crc16_update (sum, *p++);
return sum;
}
Result (avr-gcc 3.3.4, -Os -mcall-prologues) -- no suppression:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.L7:
ld r24,Z+
mov r23,r19
mov r22,r18
/* #APP */
eor r22,r24
...
eor r22,r24
/* #NOAPP */
mov r18,r22
mov r19,r23
subi r20,lo8(-(-1))
sbci r21,hi8(-(-1))
brne .L7
mov r25,r23
mov r24,r22
/* epilogue: frame size=10 */
ldi r30,2
adiw r28,10
rjmp __epilogue_restores__+32
P.S. In practice, certainly, there is no difference.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [avr-libc-dev] [bugs #10450] missing __volatile__ in CRC functions core,
Dmitry K. <=