I can't understand how which appropriate registers to use in storing input and how to use the DIV. What is wrong with my code? Would very much appreciate an explanation. Also, I don't know how to input digits more than 9. How should I do that?
Title PROGRAM TO DIVIDE TWO NUMBERS
dosseg
.model small
.stack 100h
.data
string1 db 10,13,'Enter Dividend:$'
string2 db 10,13,'Enter Divisor:$'
string3 db 10,13,'Quotient:$'
quo db 0
rem db 0
.code
main proc
mov ax, @data
mov ds, ax
lea dx,string1 ;display string1
mov ah, 09
int 21h
mov ah,1 ;store dividend in al
int 21h
mov bh,al ;moves data al -> bh
lea dx,string2 ;display string 2
mov ah, 09
int 21h
mov ah,1 ;store quotient in al
int 21h
mov bl,al ;moves data al -> bl
div bl ; ax / bl
mov quo, al ; quotient is stored in al
mov rem, ah ; remainder is stored in ah
mov dl,quo ; output quotient
sub dl, 48 ; convert ASCII to symbol
mov ah, 2
int 21h
lea dx,string3
mov ah, 09
int 21h
mov dl, 32 ; print space
mov ah, 2
int 21h
mov dl,'r' ; print char r
mov ah, 2
int 21h
mov dl, rem ; output remainder
add dl, 48
mov ah, 2
int 21h
mov ah, 4ch ; exit
int 21h ; interrupt
main endp
end main
I am using DOSBox to run the code and it assembles, but the output is wrong.