[Top][All Lists]

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

RE: [avr-gcc-list] Problem with delay loop

From: Dave Hansen
Subject: RE: [avr-gcc-list] Problem with delay loop
Date: Fri, 28 Sep 2007 12:51:29 -0400

> Date: Fri, 28 Sep 2007 14:21:38 +0530
> To: address@hidden
> Subject: Re: [avr-gcc-list] Problem with delay loop
> From: address@hidden
> CC: address@hidden
> Hi,
> On Fri, 28 Sep 2007 13:42:18 +0530, Klaus Rudolph <address@hidden> wrote:
> > The code has been optimized. Well done!
> > If you need the variable access use 'volatile'
> >
> Why does it get optimised?
Because it is allowed, and gcc is sophisticated enough to do so.

> I understand the meaning of 'volatile', but why is it required here ?
What is the meaning of volatile?  Hint: it has nothing to do with "sharing."

> It is clear that the variable is changing in the code itself (not outside it).
Precisely.  The optimizer recognized that neither the intermediate values nor even the final value of the variable had any effect on the outcome of the program, and therefore removed the calculation of those values from the code.

> Again- it worked in the older avr-gcc. Was that a bug(the fact that it worked)?
No.  It was a missed opportunity for optimization.  The program produced the same result, it just took longer to do so.
Again, you would do well to investigate the library's delay.h header and the facilities it provides.  These work very well.


Explore the seven wonders of the world Learn more!

reply via email to

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