Sunday, 14 June 2015

Read Two Decimal Which Is Less Than 10 And Display Their Sum In Assembly Language Solution.

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

Sample execution:
?99
THE SUM OF 9 AND 9 IS 18
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/

Solution:

.model small
.stack 100h
.data

ask db '?$'
str db 0ah,0dh,'THE SUM OF '
val1 db ?
str2 db ' AND '
val2 db ?
str3 db ' IS 1'
ans db ?
str4 db '$'
.code

main proc
       
    mov ax,@data
    mov ds,ax
 
    mov ah,9
    lea dx,ask
    int 21h
 
    mov ah,1
    int 21h
    mov bl,al
    mov val1,bl
 
    int 21h
    mov bl,al
    mov val2,bl
 
    add bl,val1
    sub bl,3Ah
    mov ans,bl
 
    mov ah,9
    lea dx,str
    int 21h
    mov ah,4ch
    int 21h
     
    main endp
end main

No comments:

Post a Comment