ROL AX, 8 is NOP, right?

Viewed 179

I came across an odd instruction in IDA:

ROL AX, 8

This is a NOP, correct? AX is a 1-byte register and it is being rotated by eight. Thus it is just MOV AX, AX?

2 Answers

This instruction behaves the same as

XCHG AH, AL

except it also sets CF to an undefined value. This is because AX is a 16 bit register. If this was ROL AL, 8, your description would be accurate except that ROL AL, 8 too sets CF to an undefined value.

No. ROL AL,8 would be NOP. And ROL AH,8 would also be NOP.
AX is a 16-bit register, so ROL AX, 16 would be NOP.

ROL AX,8 switches the lower BYTE AL and the higher BYTE AH.
This is an alternative to XCHG AL, AH.

The ROL instruction also changes the Overflow and the Carry flag, so it's not really a true NOP (See comments).

Related