??? 02/15/07 14:02 Modified: 02/15/07 14:03 Read: times |
#133048 - Wasn\'t saying that they were. Responding to: ???'s previous message |
These loops are not equivalent!<p>
I was not claiming that they were. I only used them as an example for typical programming tasks, like "Repeat DO_STUFF X times". Using a do/while loop with preincrement allows the compiler to skip the comparison at the entry and use DJNZ for the comparison and decrement at the exit. Using while, however, will make the compiler do a comparison at the entry (and yes, the optimizer of the Keil compiler does that even if you explicitly set the loop variable to != its exit condition), and using a postincrement will preclude the use of DJNZ. Other platforms might have different rules. "When possible, count down and compare to zero in loops" is valid for many platforms, while being irrelevant on some others, for example. |