0

From the page in the Intel docs "Introduction to x64 Assembly" you can see this code

Label: ; this is a label in assembly
 INX EAX ; increment eax
 LOOP Label ; decrement ECX, loop if not 0

Why do they say INX and not INC?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468

1 Answers1

4

There's no INX instruction in the x86 instruction set. The instruction meant to be used here is the INC instruction. Since the X key is next to the C key on most keyboards this a simple mistake to make.

Without spending much time reading it, I would have to question the value of any sort introductory document that uses the LOOP instruction in an example. There is rarely a good reason to the LOOP instruction in code being written today, or anytime in the last 25 years.

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
  • The examples using `loop` and `xchg` are one of the few bad parts of that guide. When I looked over it a while ago (actually, [the HTML version](https://software.intel.com/en-us/articles/introduction-to-x64-assembly), not PDF), it looked good enough to add to the [x86 tag wiki](https://stackoverflow.com/tags/x86/info), with a caveat [about `loop` sucking](https://stackoverflow.com/questions/35742570/why-is-the-loop-instruction-slow-couldnt-intel-have-implemented-it-efficiently). I hadn't noticed the typo :P – Peter Cordes May 01 '18 at 19:58
  • i was 97% sure it was a typo, but with over 2,000 instructions knowing about 50 didn't give me much confidence. – Evan Carroll May 01 '18 at 20:29