Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/28/06 16:39
Read: times


 
#115188 - Ptimize
Responding to: ???'s previous message
"Ptimize" is a special, shortened form of "Optimise" - Erik has just optimised-out the initial 'O' !! ;-)

Seriously, if a compiler sees that you write to a variable, and then immediately overwrite it with something else, it will quite correctly deduce that there was no point in writing the first value at all!
Therefore the compiler will not write the first value - we say that it will "optimise-out" the pointless, redundant write:
daddr = 0x32; 
daddr = 0xa1;  // This immediately over-writes the previous value
daddr = 0x32;  // This immediately over-writes the previous value 
daddr = 0xa1;  // This immediately over-writes the previous value
Therefore the above sequence of instructions would be optimised to:
daddr = 0xa1;
In fact, all the assignments in your code are redundant and could be optimised-out, since you are just writing to variables that nothing else ever reads!!

To prevent this sort of optimisation, you need to look up the 'volatile' keyword in your 'C' textbook...

List of 25 messages in thread
TopicAuthorDate
MT8980            01/01/70 00:00      
   why            01/01/70 00:00      
      Why indeed            01/01/70 00:00      
      You forget so quickly?!            01/01/70 00:00      
   Not Forget            01/01/70 00:00      
      What, then?            01/01/70 00:00      
         MT8980            01/01/70 00:00      
            shure, post it            01/01/70 00:00      
               and maybe some hardware explanation            01/01/70 00:00      
                  MT8980 and 8051 code            01/01/70 00:00      
                     Do pay attention!            01/01/70 00:00      
   Re type as your requirement            01/01/70 00:00      
      any decent compiler will ptimize the ict            01/01/70 00:00      
         Explain            01/01/70 00:00      
            you are way out in left field            01/01/70 00:00      
               Thanks            01/01/70 00:00      
                  how can I help you cook a fish when you            01/01/70 00:00      
         Ptimize            01/01/70 00:00      
            setting volatile will not make it any le            01/01/70 00:00      
               Quite so            01/01/70 00:00      
      Not typed as per requirement            01/01/70 00:00      
      Your Code            01/01/70 00:00      
   Suggestion            01/01/70 00:00      
      a suggestion            01/01/70 00:00      
         Thanks            01/01/70 00:00      

Back to Subject List