Posts with the tag CISC:

Why is n++ faster than n=n+1?

The answer is related to the old CISC cpu instructions and the way how C (or any programming language) is compiled to binary code. In almost every CISC CPU there is a special “add” instruction that is named INC (or DEC) and that instruction increments (or decrements) by 1 the value of a register (or memory). If you use another instruction for addition you have to add both operands you want to sum. That makes INC/DEC more efficient: They take less space (no space for operands). In CISC they execute faster (because you save time to load operands). The initial C compiler has been technically a simple 3 step macro processor on top of assembly so it was leaving this choice to the programmer.