2

The Error Is: -Integer divide by 0

i checked on the debugger and its working i dont understand what is going on Value is never zero so how i divide by 0?

the code:

        IDEAL

    MODEL large
P386

STACK 256

DATASEG

    Speed            DB 1
    Value            DW 1

CODESEG   

 Start:

    mov ax, @data
    mov ds, ax

@@NoValue:
    inc [Value]
    mov ax,8
    div [Value]
    cmp dx,8
    jne @@NoValue
    inc [Speed]


Exit:   
    mov ax,04c00h
    int 21h
End Start
Gad
  • 154
  • 8
  • 3
    Recall that `div [value]` divides `dx:ax` by `[value]` but you don't set up `dx`. If `dx` is not zero, this likely causes an overflow during division. Fix this by clearing `dx`. There's probably a duplicate of this somewhere. – fuz May 17 '20 at 11:23
  • 2
    @fuz: As you note this may be a division overflow (result doesn't fit into the 16-bit `ax`). It is important to note that the interrupt 0 is invoked for any divide error, not only divisor equal to zero. – ecm May 17 '20 at 13:42

0 Answers0