在装配高数课 [英] Division of high numbers in assembly

查看:213
本文介绍了在装配高数课的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一个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 (高字)和 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆