[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: |
Blake Leverett |
Subject: |
Re: [avr-gcc-list] Avr-gcc Produces Incorrect Code with -Os |
Date: |
Thu, 15 May 2008 12:02:14 -0600 |
User-agent: |
KMail/1.9.7 |
On Thursday 15 May 2008, Thomas D. Dean wrote:
> I changed the code to
>
> asm volatile("sbi 0x14, 4"::);
> atn_rad = atan2(cos_rad,sin_rad);
> asm volatile("cbi 0x14, 4"::);
>
> and the compiler still reordered the statements to put both the sbi
> and cbi statements before the atan().
>
> Changing atan2() to asin() or acos() gives the same incorrect result.
>
> Changing atan2() to sin() keeps the statements in the correct order.
>
> tomdean
If you declare atn_rad as a volatile, won't that make the order work out
correctly?
As someone already mentioned, the port accesses are already volatile, so you
should be able to use the C statments for port pin changing, and with a
volatile atn_rad, the compiler should keep everything in the source order.
Or else I misunderstand how volatile works.
Blake
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, 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