本文介绍了如何计算8086 IDIV指令的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说明(十六进制数):

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:

As far as I understand, I have to check if the leftmost bit isn't 1:

0832 -> 0000.1000.0011.0010
008a -> 0000.0000.1000.1010

由于有一个在最高位的1号的,用计算器我应该得到:

Since there's no 1's in highest bits, by using calculator I should get:

0832 MOD 008A 的剩余时间和 0832 DIV 008A DIV 部分。 国防部进入 AH DIV 应到 AH ,但我不能得到正确的答案。正确的答案是 5CEF 。我在做什么错了?

0832 mod 008a as remainder and 0832 div 008a as div part. Mod goes to AH and div should go to AH, but I can't get the correct answer. The correct answer is 5CEF. What am I doing wrong?

推荐答案

+1阅读的文档:)

请注意,您需要根据有效的操作数的大小来检查左边的一位。既然你是通过 CL ,这是一个8位值划分,你需要检查位#7,这是 1 。因此,在 CL 是负数,即 -118 。因此,

Note that you need to check the leftmost bit according to the effective operand size. Since you are dividing by CL, which is a 8 bit value, you need to check bit #7, which is 1. As such, the number in CL is negative, namely -118. So,

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

这篇关于如何计算8086 IDIV指令的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 01:55