An error like this division error is an overflow. manually handle this error, change the INT 0 address in the interrupt vectors table

.model small
.stack 100h
.data
number dw '12345'
result db 15 dup('$')
.code
main proc
    mov ax,@data
    mov ds,ax
    mov ax,number
    mov bx,offset result
    mov cx,0
l1: mov dx,0        
    div cx
    add dx,48
    push dx
    inc cx
    cmp ax,0
    jne l1
l2: pop dx
    mov [bx],dl
    inc bx
    loop l2

    mov ah,9
    mov dx,offset result
    int 21h
    mov ax,4c00h
    int 21h
main endp
end main

      

+3


source to share


1 answer


I am assuming you are using EMU8086. The error occurs when div cx

. This statement means AX = DX:AX / CX

. If CX

equal to zero, you get "divide by zero error" - in EMU8086 syntax: "divide error - overflow". You should at least take care CX

not to become null.



+2


source







All Articles