3

I am doing a project that I use doubleword(DX:AX) / word(operand). So I should get the Quotient on AX and Remainder in DX as I know.

when I do this:

MOV DX,0A8D2h    
MOV AX,08310h 
MOV BX,0F8FCh
DIV BX

I should get AD94 on AX and 4560 in DX.

AX have the right value but DX is zero for some reason when I examine registers in emu8086's built-in debugger.

I do not know if I am missing something or it is a exception for 8086 but thanks to all if you can help. I am using emu8086.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • Like I said I am using emu8086 when I press emulate I can go step by step with instructions and I can see the values of AX,BX,DX,CX etc.When i execute the div instruction. DX becomes zero and AX becomes AD94 – Serkan Özkan Mar 25 '17 at 18:51
  • 2
    If the emulator is giving you something other than those values, there is a bug in the emulator. – Michael Petch Mar 25 '17 at 18:59
  • If you are using emu8086 do you know when this bug happens by any chance? Lıke is it happening when BX is large or something else? Because it's a part of a homework which can include numbers up to 2^16-1; so at least I can explain the situation. I think i will have to try it with lots of numbers to understand when this happens ^^. – Serkan Özkan Mar 25 '17 at 19:07
  • 1
    I don't use emu8086. I just know that the results you are expecting are correct. if DX is 0 after the DIV. there is a bug in the emulator. Might want to send correspondence to the developer if there is one. I suspect that if there is a bug it is when BX is 8000h or higher. Probably a bug relating to the sign bit being set. Just a guess. What happens when BX is < 8000h? – Michael Petch Mar 25 '17 at 19:10
  • I just tried the code using debug.com (available on 32 bit windows or virtual PC with MSDOS or DOSBOX), using a100 to assemble code starting at 100, then tracing through the code. As posted, AX == AD94, and DX == 4560, If you are getting DX == 0, something is wrong. Since AX has the correct quotient, there must be another issue. Are you printing or displaying AX, and if so, is it possible that the print / display code messed up DX? – rcgldr Mar 25 '17 at 19:42
  • 2
    I am not printing or displaying anything I am just using emu8086. You can see the registers in emu8086, directly. I will discuss the situation with my lecturer after I found the reason of this bug. But while I am doing everything correctly, when result is not correct, It's really dissappointing -_- – Serkan Özkan Mar 25 '17 at 19:50
  • @SerkanÖzkan I divided those two numbers in windows programmer calculator and i got 0 as quotient. – Ahtisham Nov 24 '17 at 18:18
  • @SerkanÖzkan If you comment out DX and try to run the program you will get zero's in the AX and 8310 in DX. – Ahtisham Nov 24 '17 at 18:21
  • @Ahtisham: Then you're doing it wrong. `0xA8D28310 / 0xF8FC` is `0xad94`, and `0xA8D28310 % 0xF8FC` is `0x4560` in the calculator I used. Of course you get a different result if you zero the high half of the dividend, making it smaller than the divisor. – Peter Cordes Feb 17 '21 at 23:59

0 Answers0