0

I have this code:

.MODEL SMALL
.DATA
.CODE
.STARTUP
        MOV AX, 9801d

        MOV BH, 0d
        MOV BL, 10d

        DIV BL
    END

In summary, it divides by 10 what is present in the AX register, it works beautifully for some values, but for others, for example 9801 it doesn't work, when I run it it goes into a loop, while when I run the debugger it returns the following error:

 divide error - overflow.
 to manually process this error,
 change address of INT 0 in interrupt vector table.

I promise I'm new, so sorry if the error is due to a lack of me, thanks in advance

Binary
  • 1
  • 1
  • Does this answer your question? [divide emu 8086 assembly error](https://stackoverflow.com/questions/13941631/divide-emu-8086-assembly-error) – robere2 Feb 23 '23 at 15:46
  • Ages since I've done anything in assembler, but doesn't DIV BL store the quotient in AL and remainder in AH? 9801/10=980, which is too big for AL? – C.Evenhuis Feb 23 '23 at 15:59
  • @C.Evenhuis, right observation, so what should I do? – Binary Feb 23 '23 at 16:01
  • 1
    You could do DX:AX div BX. That means you'd have to set DX to 0 as well – Michael Petch Feb 23 '23 at 16:20
  • @Michael Petch, could you give me an example? – Binary Feb 23 '23 at 17:28
  • 1
    `MOV AX, 9801d` `XOR DX, DX` `MOV BX, 10d` `DIV BX`. That will take the 32-bit value in DX:AX (0x00009801) and divide it by BX (0x10). The 16-bit quotient will be in AX and the 16-bit remainder will be in DX. Note: XORing a register with itself has the same effect at setting that register to 0 – Michael Petch Feb 23 '23 at 18:13

0 Answers0