[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Problems with avr-gcc vers 3.0

From: Jason Kyle
Subject: Re: [avr-gcc-list] Problems with avr-gcc vers 3.0
Date: Fri, 10 Aug 2001 22:15:26 +1200

See the earlier posts regarding redundant loop optimisations, as I understand it this is gcc related and not specific to the avr port. Some think it is a bug but others describe it as normal.


Jason Kyle

At 09:53 7/08/2001 +0800, Peter N Lewis wrote:
Is there something I must know?

This delay routine does *nothing* as far as the rest of the program is concerned, so it would be a perfectly legitimate compilation of it to translate it in to:

void delay(void)

counter is not externally visible, so its value on completion is irrelevant.

If you want to do a delay routine, you should do it in assembler code, since otherwise there is no reasonable guarantee of what result you'll get on any given compiler. Even if you label the counter variable "volatile" and the compiler actually has to count through them all in order, the amount of time it will take is pretty much random depending on the compiler version, optimizing flags, etc.

Better yet would be to use a timer of course, although that is not always possible.

I have to admit, it is an odd optimization!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]