Hello all,
While developing the optimizer for my compiler I noticed something funny:
The XCHG instruction (which came in so late in my compiler/optimizer back end because it's a slow and because of this almost useless instruction on modern CPU's), in the form XCHG EAX,EAX has the opcode $90. Surprise, that's just the one of NOP. Conclusion, NOP never existed on x86 CPU's.. it was just one form of the XCHG instruction (which did nothing, thus was suitable as a NOP). Yet *this* form of the XCHG instruction has been optimized in modern CPU's, unlike e.g. XCHG EBX,ECX. I felt it was quite funny.. and although unimportant, I wanted to share it. :)

Posted on 2002-03-11 16:07:48 by Maverick
That is very true, and funny - two mnemonics for the same instruction. There is a huge list of instructions that do nothing. :)
Posted on 2002-03-11 16:23:40 by bitRAKE
And different opcodes that do exactly the same thing (for example the mem,reg and reg,mem when mem is used as a reg) ;)
Posted on 2002-03-11 16:29:56 by Maverick
A feature I wanted to add to my assembler is optimization for compression using this kind of info, and parts of the code which don't have to be anything exact. ;)
Posted on 2002-03-11 16:35:31 by bitRAKE

Interesting observation, XCHG EAX,EAX is one of the old versions used to do the NOP operation a long time ago but they are not without their uses, depending on the padding requirement, dead instructions can sometimes help when designing a loop where you are after pairing or changing the instruction count.


Posted on 2002-03-11 16:37:28 by hutch--
Hutch: yup, for example, to pad 3 bytes I use LEA EAX,
Posted on 2002-03-11 16:45:08 by Maverick
bitRAKE: yup, code size is very important for speed, also (but not only) because it will make a better use of the cache.. which is very important.

BTW: how's the development of your optimizer proceeding?
Posted on 2002-03-11 16:48:38 by Maverick
Slowly. :(
Posted on 2002-03-11 16:51:23 by bitRAKE
Good things do not take 5 minutes to write. ;)
Posted on 2002-03-11 17:05:26 by Maverick