??? 07/06/05 13:56 Read: times |
#96694 - urban legends Responding to: ???'s previous message |
The whole point of 'C' is its platform independence.
In the "small embedded" world ('51 PIC, XA etc) platform independence is an urban legend. The software is so tightly coupled to the hardware that "platform independence" is an illusion. Performing the sort of 'micro optimisations' being discussed here to save a few cycles may make us feel very clever but are a waste of time unless absolutely necessary. They may actually reduce performance when code is changed elsewhere, or the compiler version is upgraded. possible, but, to take an example, the "count down a loop" which adapt to the hardware will hardly ever be a deteriment. If 'micro optimisations' are necessary they are best done in assembler which will indeed require knowledge of the processor. The discussion is not about 'micro optimisations' which, in the best case, will save a cycle or two, but about habits that will save "save a cycle or two" in hundereds of places. is it 'micro optimisations' to know that, for an 8 bit processor, a char is more efficient than an int - should the compiler have the "intelligence" to change an int to a char, or even a bit, as part of optimization - I would hope not. "No, there is no need to globally go back to writing assembler, but that does not mean that you do not need to know it." Indeed, but you don't need to know it to write optimum 'C'. Here we disagree totally. How can you choose count up or count down without knowing assembler. I'm not too sure what a 'Cnatic' is. and What is this 'real C' stuff anyway? A Cnatic (C fanatic) is someone that believe that C is universal to the extent that e.g. malloc should be generally used on a '51. "real C" is code written by a Cnatic with total disregard for efficiency. Erik |