[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os
From: |
Paulo Marques |
Subject: |
Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os |
Date: |
Thu, 15 May 2008 18:03:41 +0100 |
User-agent: |
Thunderbird 1.5.0.14 (X11/20071210) |
Thomas D. Dean wrote:
From 'info gcc',
...
You can prevent an `asm' instruction from being deleted, moved
significantly, or combined, by writing the keyword `volatile' after the
`asm'.
This only means that they are not reordered with respect to other
"volatile asm" statements. Note the "moved significantly" part: if the
other instruction is not "significant", then it might be moved over it.
Yes, I do agree that the outcome might be somewhat surprising, though.
Changing the code fragment to
...
dtostrf(cos_rad,6,3,&line4[14]);
line3[20] = ' ';
line4[20] = ' ';
asm volatile("sbi 0x1b,4" : :);
atan_rad = atan2(cos_rad,sin_rad);
asm volatile("cbi 0x1b,4" : :);
dtostrf(atan_rad,6,3,&line4[26]);
...
does not alter the result.
The PORTx accessors are already volatile, so this doesn't change much.
The main problem here is probably that the atan2 function is declared to
be __attribute__((const)), which gives teh compiler more leeway to move
it around...
--
Paulo Marques
Software Development Department - Grupo PIE, S.A.
Phone: +351 252 290600, Fax: +351 252 290601
Web: www.grupopie.com
"Power corrupts. Absolute power is kind of neat." John Lehman
- Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os, (continued)
- Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os, Thomas D. Dean, 2008/05/16
- RE: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os, Stu Bell, 2008/05/16
- RE: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os, John Regehr, 2008/05/16
- RE: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os, Stu Bell, 2008/05/16
- Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os, Thomas D. Dean, 2008/05/16
- Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os, David Brown, 2008/05/17
Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os, Thomas D. Dean, 2008/05/15
Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os, Thomas D. Dean, 2008/05/15
- Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os,
Paulo Marques <=
Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os, hutchinsonandy, 2008/05/15
Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os, Alex Wenger, 2008/05/15
Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os, David Brown, 2008/05/15
FW: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os, Ron Kreymborg, 2008/05/23