说明(十六进制数字):
mov ax, 0832
mov cx, 008a
idiv cl
文档说:
when operand is a byte:
AL = AX / operand
AH = remainder (modulus)
来源:http://www.electronics.dit.ie/staff/tscarff/8086_instruction_set/8086_instruction_set.html#IDIV
据我了解,我必须检查最左边的位是否不是 1:
0832 -> 0000.1000.0011.0010
008a -> 0000.0000.1000.1010
由于最高位没有 1,通过使用计算器我应该得到:
0832 mod 008a
作为余数,0832 div 008a
作为 div
部分。 Mod
转到 AH
,div
应该转到 AH
,但我无法得到正确的答案。正确答案是5CEF
。我做错了什么?
最佳答案
+1 用于阅读文档:)
注意,需要根据有效操作数大小检查最左边的位。由于您要除以 CL
(这是一个 8 位值),因此您需要检查位 #7,即 1
。因此,CL
中的数字为负数,即 -118
。所以,
AL = 0832h / -118 = 2098 / -118 = -17 = EFh
AH = 2098 - (-17 * -118) = 92 = 5Ch
关于assembly - 如何计算8086 IDIV指令的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33134692/