ASM 86整数溢出 [英] ASM x86 integer overflow

查看:127
本文介绍了ASM 86整数溢出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GetLCM PROC
tryAgain:
   mov bx, 0
   inc Multiple
   mov ax, UserInputNum1              ;Move UserInputNum1 to the 16 bit Register
   mov bx, Multiple
   div bx                             ;<-------Error here
   cmp dx,0                           ;If dx is not zero then there is a remainder
   jne tryAgain                       ;If not equal jump
ret
GetLCM ENDP

我一直努力的div这两个数字的时候得到一个整数溢出错误。当我尝试使用DIV它打破了。

I keep getting a integer overflow error when trying to div these two numbers. It breaks when i try to use div.

我试图找到由用户输入的两个数的最小公倍数。我决定尝试将每个号码找到素数第一,然后每次一被发现用户输入对方号码进行比较。当然,我会在同一时间做这两个数字,但截至目前,我想只得到过去的这个错误。

I am trying to find the least common multiple of two numbers entered by the user. I decided to try to divide each number to find prime numbers first then compare each time one is found to the other number the user entered. Of course I would be doing both numbers at the same time, but as of now I am trying to just get past this error.

这只是我在ASM第五周让我有点搞不清为什么发生这种情况。
此外,我想补充一点,我也想使这项工作为32位数字,以及。我的想法是使用指针。这是做到这一点的好办法?
感谢您的帮助!

This is only my fifth week in ASM so I am a little confuse why this is happening. Also I would like to add that I would also like to make this work for 32bit numbers as well. My idea is to use pointers. Is this a good way to do this? Thanks for any help!

推荐答案

再次阅读上的 DIV 指令。什么是由什么分呢?你缺少设定一个操作数为一些明智的值。

Read up on the div instruction again. What is divided by what? You are missing to set one of the operands to some sensible value.

这篇关于ASM 86整数溢出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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