鸸鹋分8086装配误差 [英] divide emu 8086 assembly error

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

问题描述


  

可能重复:结果
   ASM 86整数溢出


我得到一个鸿沟无差错溢出,我不知道为什么。
下面是完整的code重现错误

 包括emu8086.inc组织100H       MOV AX,2
       MOV BX,10
       DIV BX       MOV AX,2
       MOV BX,2
       DIV BX
       RET


解决方案

尝试添加 XOR DX,DX 前各 DIV ,看看是否有没有帮助。

既然你指定一个16位的目标, DIV 分歧 DX:AX 由该目标。如果 DX 开出含有大量的(更准确地说,是什么,但相当数量少),结果就会溢出。即使不会溢出,你的结果将不只是 / BX ,你显然打算。

Possible Duplicate:
ASM x86 integer overflow

I get a divide error- overflow and am not sure why. Here is the complete code that reproduces the error

include emu8086.inc

org 100h

       mov ax, 2 
       mov bx, 10
       div bx

       mov ax, 2
       mov bx, 2
       div bx   
       ret

解决方案

Try adding xor dx, dx before each div and see if that doesn't help.

Since you're specifying a 16-bit target, div divides dx:ax by that target. If dx starts out containing a large number (more accurately, anything but quite a small number), the result will overflow. Even if it doesn't overflow, your result won't just be ax/bx as you apparently intend.

这篇关于鸸鹋分8086装配误差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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