divide emu 8086 assembly error

10,819

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.

Share:
10,819
devide and code
Author by

devide and code

Updated on June 04, 2022

Comments

  • devide and code
    devide and code almost 2 years

    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
    
  • devide and code
    devide and code over 11 years
    thanks for the quick response and explanation. worked perfectly