I have a code segment which
1. sets a bit in PORTA.
2. calls atan2.
3. clears the same bit in PORTA.
The compiler produces code that
1. sets the bit in PORTA.
2. clears the same bit in PORT.
3. calls atan2.
With -O0, the code is correct.
# uname -a
FreeBSD dv6000.tddhome 7.0-STABLE FreeBSD 7.0-STABLE #0: Sun May 4 07:58:25
PDT 2008 address@hidden:/usr/src/sys/GENERIC i386
# avr-gcc --version
avr-gcc (GCC) 4.2.2
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The code fragment,
...
dtostrf(cos_rad,6,3,&line4[14]);
line3[20] = ' ';
line4[20] = ' ';
TRACE_ON(TRACE4); // portb |= _bv(04)
atan_rad = atan2(cos_rad,sin_rad);
TRACE_OFF(TRACE4); // portb &= ~_bv(04)
dtostrf(atan_rad,6,3,&line4[26]);
...