??? 05/05/08 16:04 Modified: 05/05/08 16:05 Read: times |
#154434 - assumptions Responding to: ???'s previous message |
So it's clear that a sufficiently smart compiler could, should, and would calculate
While i might not have chosen the best example as Russ' version evidently is "sufficiently smart". a person would be ill-advised to base his coding style on such a superstitious notion "superstitious notion" or not, you should, especially when working with limited resource processors, try to "make it easier" for the compiler. No, I am not advocating that you 'chew' every line, that would be very counterprocuctive, but here is another eaxmple where "a sufficiently smart compiler" might figure it out, but Keil definitely does not. what, coded in "Real C" was (in the same function) if(ReadPagedFlashC((U16) &GE1_TXCHp->TXCHtype, GC_E1_TXINpg)) .... if(ReadPagedFlashC((U16) &GE1_TXCHp->TXCHtype, GC_E1_TXINpg)) .... if(ReadPagedFlashC((U16) &GE1_TXCHp->TXCHtype, GC_E1_TXINpg)) .... ad nauseam I changed to PCHCtype = ReadPagedFlashC((U16) &GE1_TXCHp->TXCHtype, GC_E1_TXINpg); if (PCHCtype) .... if (PCHCtype) .... both examples are, of course, correct, but which is the efficient one (both code size and speed) Erik |
Topic | Author | Date |
"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 |