This article claims that each register has an intended purpose and more importantly,
When the engineers at Intel designed
the original 8086 processor, they had
a special purpose in mind for each
register. As they designed the
instruction set, they created many
optimizations and special instructions
based on the function they expected
each register to perform. Using
registers according to Intel’s
original plan allows the code to take
full advantage of these optimizations.
Unfortunately, this seems to be a lost
art. Few coders are aware of Intel’s
overall design, and most compilers are
too the simplistic or focused on
execution speed to use the registers
properly. Understanding how the
registers and instruction set fit
together, however, is an important
step on the road to effortless
size-coding.
Are there any other sources to corroborate this article? If so, I’d really like to check it out.
Please note I’m not talking about situations where fast operations like STOS uses edi – I’m just wondering if there is any performance degradation if I use eax and esi as counters instead of ecx or is it just about readability?
No, not really anymore — or at least not very often anyway. Using ECX as a counter lets you use the LOOP instruction. At one time, that was a significant advantage, but on most recent CPUs, a LOOP takes longer to execute than the combination of DEC ECX/JNZ wherever. The possible advantage is that it reduces memory bandwidth usage, which is a bottleneck more and more often. It can also be an advantage when/if you can use the other forms like LOOPNZ, which can be relatively complex to simulate with separate instructions.