在装配高数课 [英] Division of high numbers in assembly
问题描述
我试图找到一个crusor的位置与1896年的一个数组(成为2D整个控制台,79 * 24)。为此,我拿了位置,并通过79分吧。
I tried to find a location of a crusor with an array of 1896(becomes the whole console in 2D, 79*24). For this I took the location and divided it by 79.
MOV AX, [Y-16H]
DEC AX
MOV BX, 79
DIV BX
MOV Z, DL
ADD Z, DH
MOV DL, Z
MOV Z, AL
ADD Z, AH
MOV DH, Z
我得到一个溢出错误。你能告诉我什么我做错了吗?也许提出一个解决方案?
I get an overflow error. Can you tell me what am I doing wrong please? maybe suggest a solution?
推荐答案
DIV BX
除以 DX $形成的32位数字C $ C>(高字)和
AX
(低字)由 BX
。因此,你需要清除 DX
(如 XOR DX,DX
)之前的分工,以避免溢出。
DIV BX
divides the 32-bit number formed by DX
(high word) and AX
(low word) by BX
. You therefore need to clear DX
(e.g. XOR DX,DX
) prior to the division to avoid an overflow.
顺便说一句,你确定你不想要了80分?我从来没有听说过一个79列控制台,虽然我对这些问题没有专家
By the way, are you sure you don't want to divide by 80? I've never heard of a 79-column console, although I'm no expert on such matters
这篇关于在装配高数课的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!