2

如何在不使用 DIV 指令但使用 shift 和 add 方法的情况下在 Assembly 中划分两个数字?

我用乘法做到了,这是我的代码:

mov bl, 56H ;For example
mov dl, 79H
;start
mov bh, 00H
mov dh, 00H
xor di, di
mov cx, 08H
L1:
shr dx, 1 ;shifting the multiplier
jnc nxt
add di, bx ;adding the multiplicand to the result register di
nxt:
shl bx, 1 ;shifting the multiplicand
loop L1

第二个问题:我的老师告诉我们,有一个指令叫做 MOVZE 来做我在第 4 行和第 5 行所做的事情,但它不起作用?我使用emu8086模拟器。

4

1 回答 1

-4

您不能使用移位和加法将一个数字除以另一个数字。不知道谁告诉你可以做到的。右移一位相当于除以二。但是您不能通过移位来划分为随机数。

于 2013-11-23T19:32:44.167 回答