VOGONS


Bug report: idiv

Topic actions

First post, by bavi

User metadata
Rank Newbie
Rank
Newbie

Dear developers!

I have found a new error in DOSBox.
The instruction "idiv" crashes DOSBox completely when trying to divide 0x80000000 on 0xFFFF (-0x80000000 on -1):

mov      dx, 8000h
mov ax, 0
mov bx, 0FFFFh
idiv bx

The expected behaviour is to raise the exception 0.
It seems that the error does not happen with other values.

Would be grateful to fix...

Reply 1 of 4, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

How does your test application perform on a real system?

Reply 2 of 4, by bavi

User metadata
Rank Newbie
Rank
Newbie

Well, as I wrote, it raises the exception 0 ("Int 0") when it is run on a real hardware...

I used the following program to find the error:
http://ompldr.org/vYmk4aQ/IDIV_80.zip

It prints "Success" and quits when it is run under pure DOS, but it crashes the emulator when it is run under DOSBox.

Compare with the version which runs normally:
http://ompldr.org/vYmk4Zw/IDIV_80.zip

This is 16-bit division, but maybe the same error exists in the 8-bit and in the 32-bit versions of the instruction.

Reply 3 of 4, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Well there it code to care about these cases, don't see anything wrong there at the moment. I'll try to check your code later, thanks for posting it.

Reply 4 of 4, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

It's only the -MININT/-1 case that's wrong (ie. crashing), is that right?
Causes an arithmetic exception that would have to be checked beforehand.