【问题标题】:How to compute the result of 8086 IDIV instruction?如何计算 8086 IDIV 指令的结果?
【发布时间】:2015-10-14 20:10:17
【问题描述】:

说明(十六进制数字):

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。我做错了什么?

【问题讨论】:

    标签: assembly x86-16


    【解决方案1】:

    +1 用于阅读文档 :)

    请注意,您需要根据有效操作数大小检查最左边的位。由于您要除以CL,这是一个 8 位值,因此您需要检查位 #7,即1。因此CL中的数字为负数,即-118。所以,

    AL = 0832h / -118 = 2098 / -118 = -17 = EFh
    AH = 2098 - (-17 * -118) = 92 = 5Ch
    

    【讨论】:

      猜你喜欢
      • 2017-09-20
      • 1970-01-01
      • 2015-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多