avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] efficiency of assigning bits


From: E. Weddington
Subject: Re: [avr-gcc-list] efficiency of assigning bits
Date: Mon, 14 Mar 2005 13:38:48 -0700
User-agent: Mozilla Thunderbird 0.7.3 (Windows/20040803)

David Willmore wrote:

It's prudent to declare them as volatile because you *don't* want the optimizer to optimize away statements involving hardware registers. It's important that when you set or clear a bit in a register that it actually happens in the way and order that you specify in order to control the hardware and also because the hardware may change those values in ways that the compiler cannot see beforehand.

Right, that's why there is volatile--for when the programmer wants
explicit control over when/what happens to a variable.  But, by
always declairing it volatile, you take away the ability of the
compiler to optimize things--when they might be okay.  But, the
user can do that by using a not volatile temp variable for all of
the intermediate stuff and they assigning it back to the volatile
at the end.

Exactly.

PS. Reply to the list and not to me personally.

Well, I meant to end the discussion and didn't think the list would
much care.  I just wanted the only other party to the email to know
it was done, too. :)


What?! Are you kidding?! These things take a life of their own!
As they say in Soviet Russia: the thread owns you! :-)

You should see the staggering list of replies! Or is it "You should see the list of staggering replies!"? It makes the head spin!

Someday, some poor soul will be interested in this very topic and will want to search the archives for such elucidation!
So keep it on the list! :-)

Eric




reply via email to

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