Tamas Rudnai wrote: > On 4 June 2013 14:12, Dave Tweed wrote: > > A lot of us got into the habit of writing ++i "by default" (i.e., unles= s > > we really needed i++ in an expression), because many simple-minded > > small-system C compilers generate more efficient code for ++i than for > > i++, even if the result isn't being used. >=20 > That's what I was thinking of, however, would not it be the same? Would n= ot > compiler generate "INCF i,f; MOVF i,w" as opposed to "MOVF i,w; INCF i,f" > -- same amount of instructions? Yes, it would probably be a wash on the PIC. The specific example I was thinking about was for the 8051 architecture. I don't remember the exact sequences it generated, but "i++" was several instructions longer than "++i= " because it moved the pre-increment value to a register even though it wouldn't be used. > I can imagine there is a difference when you do a "do..while(i--)" or > "while(i--){}", so that the compiler can do a single DECFSZ..GOTO. But > then "--i" would be worse than "i--" in this matter, right? No, DECFSZ is exactly equivalent to while(--i), because it tests the result of the decrement. while(i--) would require saving the pre-decremented value to test. -- Dave Tweed --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .