flat assembler
Message board for the users of flat assembler.

flat assembler > DOS > division bug?

Author
Thread Post new topic Reply to topic
kty11



Joined: 30 Dec 2012
Posts: 21
Location: south korea
is there anyone suffer division bug in dos programming?
following code with dx not 0, it shutdown
Code:
org 100h
mov dx, 0
mov ax, 10
mov bx, 10
div bx
add ax, '0'
int 29h   
mov ax, 00h
int 16h
mov ax, 4c00h
int 21h
    


and following code with dx greater than 0xf, it shut down
Code:
org 100h
mov dx, 0xf
mov ax, 10
div word [divby]
add ax, '0'
int 29h
mov ax, 00h
int 16h
mov ax, 4c00h
int 21h
divby:
        dw 0x10           

    


I have no idea why I can't divide.
any solution?

_________________
since 1990 November 4th
Post 11 Jan 2013, 06:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16128
Location: Hyperborea
DX:AX / divby == 0x000f0010 / 0x0010.

It will overflow with the high portion in DX greater than the divisor.
Post 11 Jan 2013, 06:55
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.