Assembly: ROL instruction correct?

Lets say I have the following value stored in AX: 1000100001001 and in CL I have the value of 1.

When I perform the ROL AX, CL instruction, my SW tells me that the content of AX is now 10001000010010.

Shouldn't however the correct answer be 00010000100101? (I ROL all the bits to the left thus the MSB comes up as LSB on the right?)


Your debugger fooled you by leaving out the leading zeros.

   1 0001 0000 1001

is actually

0001 0001 0000 1001

so yes, one left-rotation of that is

0010 0010 0001 0010

Note that rol ax, cl is pretty pointless if you know cl is 1. rol by 1 has a special encoding, and there's a rol reg, imm8 encoding you can use for other counts.


You're forgetting about the other bits that are set to zero (0) and you don't denote but are still there: 0001 0001 0000 1001 (16 bits). When you roll this, the answer is as given.

链接地址: http://www.djcxy.com/p/72402.html

上一篇: x86 MASKMOVDQU指令的所有16个字节必须是有效内存吗?

下一篇: 大会:ROL指令是否正确?