[Assembly 8086] Add Two Number










Question 8 [Charles Marut] :

Write a program to (a) display a "?", (b) read two decimal digits
who.se sum "is less than 10, (c) display them and their sum on the
next line, with an appropriate message.

Sample execution:
?27
'!'HE SlJM OF 2 .'\ND 7 IS 9





Solution:

.model small
.stack 100h
.data 
msg db 'THE SUM OF$' 
msg1 db '  $'
msg2 db 'AND$'
msg3 db 'IS$'
.code
 main proc
    
    mov dl,'?'
    mov ah,2
    int 21h
    
    
    mov ah,1
    int 21h
    
    mov bl,al
    
    mov ah,1
    int 21h
    
    mov cl,al
    
  
    
    mov ah,2
    mov dl,0dh
    int 21h
    mov dl,0ah
    int 21h  
    
    mov ax,@data
    mov ds,ax
    lea dx,msg 
    mov ah,9
    int 21h
    
    
    
    lea dx,msg1
    mov ah,9
    int 21h 
    
    mov ah,2
    mov dl,bl 
    int 21h
    
    lea dx,msg1
    mov ah,9
    int 21h 
    
    lea dx,msg2
    mov ah,9
    int 21h 
    
    
    lea dx,msg1
    mov ah,9
    int 21h  
    
    mov ah,2
    mov dl,cl 
    int 21h
    
     
    lea dx,msg1
    mov ah,9
    int 21h  
    
     
    lea dx,msg3
    mov ah,9
    int 21h 
    
    lea dx,msg1
    mov ah,9
    int 21h  
    
    
    
    
     
   
    add bl,cl
    
    sub bl,48d
    
    mov dl,bl
    mov ah,2
    int 21h  
    
    
    mov ah,4ch
    int 21h
    
    
   main endp

   end main
    





Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment