divide emu 8086 assembly error [duplicate]

情到浓时终转凉″ 提交于 2019-11-28 05:41:20

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/13941631/divide-emu-8086-assembly-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!