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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/05/08 17:26
Modified:
  05/05/08 17:55

Read: times


 
#154438 - I took a \'known\' example
Responding to: ???'s previous message
I would guess that no compiler could figure that one out. Consider that the ReadPagedFlash() function might be in a different module than the one being compiled, or even in a precompiled library of some sort that the present compiler knows nothing about. So the compiler has no choice but to call ReadPagedFlash() for each of the 'if' statements because for all it knows, ReadPagedFlash() might return a different result each time it is called.
you are right, I took a 'known' example (no change while in the module) and correct, the compiler could not 'know' that.

But in a sense, you didn't really make it "easier" for the compiler to do the optimization; you did the optimization manually by applying information that the compiler had no way to get on its own.
and that, gentlemen, is the case about 'optimal' C. I may have overstepped some bounds when referring to "making it easier for the compiler" but do recall some long ago doing checks of a) and b) where b), indeed, "made it easier for the compiler" what they were is long forgotten

This is pretty interesting stuff. I know what you're trying to get at, and I've been trying (without success) to come up with a better example.
so, maybe we should forget about the compilers involvement and just continue with "compiler independent efficient C". which, of course, does not change the subject from "real C" vs '51 C.

The issue is that the first example I posted above was, indeed, the way a timing critical function was coded by a "PC programmer doing the '51"

Erik

PS I do respect those that can program the '51 efficiently and also do the PC, I am, by no means stating that the ability to program a PC makes you incapable of programming the '51, just that it takes two different mindsets. On the PC you can 'afford' to "write for the programmers convenience" (I am not saying you should) on the '51 (in most cases) you can not.

List of 20 messages in thread
TopicAuthorDate
"Real C" vs '51 C            01/01/70 00:00      
   there is nothing wrong except...            01/01/70 00:00      
      if you are not , why are you even here            01/01/70 00:00      
         *(buffer+8+index)?            01/01/70 00:00      
            none of the above            01/01/70 00:00      
               OK then how?            01/01/70 00:00      
   like this            01/01/70 00:00      
      but it's basically the same...            01/01/70 00:00      
      YCMV            01/01/70 00:00      
      No            01/01/70 00:00      
         assumptions            01/01/70 00:00      
            Re: assumptions            01/01/70 00:00      
               I took a \'known\' example            01/01/70 00:00      
                  Compiler-independent efficient C            01/01/70 00:00      
                     a clarification and an example            01/01/70 00:00      
                        Two kinds of "efficiency"            01/01/70 00:00      
                     Compiler smarter than coder            01/01/70 00:00      
                        Getting the least out of your compiler            01/01/70 00:00      
   Real C is inherently reentrant            01/01/70 00:00      
      which, even when possible, often is ill advised            01/01/70 00:00      

Back to Subject List