flat assembler
Message board for the users of flat assembler.

Index > DOS > division bug?

Author
Thread Post new topic Reply to topic
kty11



Joined: 30 Dec 2012
Posts: 21
Location: south korea
kty11 11 Jan 2013, 06:41
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: 20358
Location: In your JS exploiting you and your system
revolution 11 Jan 2013, 06:55
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.