I tried to figure out the difference in speed between equal loops, loop
loops and built-in rep
loops. I wrote three programs to compare behavior:
Program 1
_start: xor %ecx,%ecx 0: not %ecx dec %ecx jnz 0b mov $1,%eax xor %ebx,%ebx int $0x80
Program 2
_start: xor %ecx,%ecx not %ecx loop . mov $1,%eax xor %ebx,%ebx int $0x80
Program 3
_start: xor %ecx,%ecx not %ecx rep nop
It turned out that the third program does not work as expected, and some recherche tell me that rep nop
aka pause
does something completely unrelated.
What are the rep
, repz
and repnz
when the command following them is not a string instruction?
source share