Re: [avr-gcc-list] Re: loop deleted using optimization

2007-03-07 Thread Joerg Wunsch
Ben Jackson [EMAIL PROTECTED] wrote:

 It would probably work to add an empty asm, as long as you used the
 __volatile attribute to scare gcc away from reordering code in the
 loop.

asm volatile(:::memory);

works.  However, as others already noted, the functions from
util/delay.h are preferrable, as their execution cycle count is
simply known beforehand.

-- 
cheers, Jorg   .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


[avr-gcc-list] Re: loop deleted using optimization

2007-03-06 Thread Ben Jackson
 Why does avr-gcc delete my empty for loops if I compile with 
 optimization on?
 I am able to preserve the loop if I add a NOP in the loop but that will 
 eat up one clock cycle.  Is there a way to preserve the empty loops 
 without adding any NOP clock cycles?

It would probably work to add an empty asm, as long as you used the
__volatile attribute to scare gcc away from reordering code in the
loop.  So, for () { __asm __volatile () ; }

(I note I wasn't able to get gcc 3.3 to optimize away the loop on i386)

-- 
Ben Jackson AD7GD
[EMAIL PROTECTED]
http://www.ben.com/


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list