Write an assembly language program to add all the elements of a table which are between 50 and 100 only. Display the result as the decimal value.
My soln:
.model small
.stack 64
.data
table db 0, 25, 50, 75, 100, 125, 150, 175, 200
ten db 10
.code
main proc
mov dx, @data
mov ds, ax
lea si, table
mov dx, 0
mov bx, 0
mov cx, 9
l2: mov ax, [si]
cmp ax, 50
jb l1
cmp ax, 150
ja l1
add ax, dx
mov dx, ax
l1: inc si
loop l2
l3: mov dx, 0
div ten
add dx, 30H
push dx
inc bx
cmp ax, 0
jne l3
mov ah, 02H
l4: pop dx
int 21h
dec bx
jnz l4
mov ax, 4c00H
int 21H
main endp
end main
It's showing an error -->> divide error - overflow.to manually process this error,change address of INT 0 in interrupt vector table.
What's the solution for this. Thanks!