.model small
.stack 100h
.data
a dw ?
b dw ?
m1 db "enter the first number: $"
m2 db 0ah,0dh,"enter the second number:$"
m3 db 0ah,0dh,"sum is:$"
m4 db 0ah,0dh,"difference is:$"
m5 db 0ah,0dh,"product is:$"
m6 db 0ah,0dh,"quotient is:$"
.code
start:
mov ax,@data
mov ds,ax
;TO INPUT NUMBER ONE
lea dx,m1 ;print message one
mov ah,09h
int 21h
mov ah,01h ;input 10s digit of number one
int 21h
sub al,30h ;convert to number
mov bl,0ah ;mov 10 to bl
mul bl ;multiply 10 to al
mov bl,al ;copy to bl
mov ah,01h ;input 1s digit of number one
int 21h
sub al,30h ;convert to number
add bl,al ;add to bl
lea DI,a ;load address of a to index reg
mov [DI],bl ;save bl to location of b (a = bl)
lea dx,m2 ;print message two
mov ah,09h
int 21h
;TO INPUT NUMBER TWO
mov ah,01h ;input 10s digit of number two
int 21h
sub al,30h ;convert to number
mov bl,0ah ;mov 10 to bl
mul bl ;multiply 10 to al
mov bl,al ;copy to bl
mov ah,01h ;input 1s digit of number two
int 21h
sub al,30h ;convert to number
add bl,al ;add to bl
lea DI,b ;load address of b to index reg
mov [DI],bl ;save bl to location of b (b = bl)
;TO PRINT SUM RESULT
lea dx,m3 ;load effective address of add to dx
mov ah,09h ;print result message
int 21h
;ACTUAL ADDITION
mov ax,000h
mov ax,a ;mov a to ax
mov bx,b ;mov b to bx
add ax,bx ;add bl to al
mov bl,0ah ;save 10 to bx
mov dx,0000h ;clear
mov cx,0000h ;clear
div bl ;div ax by bx
mov cx,dx ;save dx(remainder) in bx because dx overwritten in printing
add al,30h ;add 30 to convert to ascii
mov dl,al ;mov to ax to print
mov cl,ah
mov ah,02h ;print quotient
int 21h
mov dl,cl ;mov to bx to print
add dl,30h
mov ah,02h ;print remainder
int 21h
;TO PRINT DIFFERENCE RESULT
lea dx,m4 ;load effective address of add to dx
mov ah,09h ;print result message
int 21h
;ACTUAL SUBTRACTION
mov ax,000h
mov ax,a ;mov a to ax
mov bx,b ;mov b to bx
sub ax,bx ;sub bl to al
mov bl,0ah ;save 10 to bx
mov dx,0000h ;clear
mov cx,0000h ;clear
div bl ;div ax by bx
add al,30h ;add 30 to convert to ascii
mov dl,al ;mov to ax to print
mov cl,ah
mov ah,02h ;print quotient
int 21h
mov dl,cl ;mov to bx to print
add dl,30h
mov ah,02h ;print remainder
int 21h
;TO PRINT PRODUCT RESULT
lea dx,m5 ;load effective address of add to dx
mov ah,09h ;print result message
int 21h
;ACTUAL MULTIPLICATION
mov ax,000h
mov ax,a ;mov a to ax
mov bx,b ;mov b to bx
mul bx ;mul bl to al
mov bl,0ah ;save 10 to bx
mov dx,0000h ;clear
mov cx,0000h ;clear
div bl ;div ax by bx
add al,30h ;add 30 to convert to ascii
mov dl,al ;mov to ax to print
mov cl,ah
mov ah,02h ;print quotient
int 21h
mov dl,cl ;mov to bx to print
add dl,30h
mov ah,02h ;print remainder
int 21h
;TO PRINT QUOTIENT RESULT
lea dx,m6 ;load effective address of add to dx
mov ah,09h ;print result message
int 21h
;ACTUAL DIVISION
mov ax,000h
mov ax,a ;mov a to ax
mov bx,b ;mov b to bx
div bl ;div bl to al
mov bl,0ah ;save 10 to bx
mov dx,0000h ;clear
mov cx,0000h ;clear
div bl ;div ax by bx
add al,30h ;add 30 to convert to ascii
mov dl,al ;mov to ax to print
mov cl,ah
mov ah,02h ;print quotient
int 21h
mov dl,cl ;mov to bx to print
add dl,30h
mov ah,02h ;print remainder
int 21h
mov ah,4ch ;return control to the terminal
int 21h
end start