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



Write a program to (a) display a "?", (b) read two decimal digits
whose sum "is less than 10, (c) display them and their sum on the
next line, with an appropriate message.
Sample execution:
?27
THE SUM OF 2 AND 7 IS 9

/*
*
* Prosen Ghosh
* American International University - Bangladesh (AIUB)
*
*/
TAG: EASY, 8086 MICROPROCESSOR, ASSEMBLY LANGUAGE CHAPTER 4 , PROGRAMMING EXERCISE .

Solution:

.MODEL SMALL
.STACK 100H
.DATA
STR1 DB 0AH,0DH,'THE SUM OF '
FIRSTNUM DB ?
STR2 DB ' AND '
SECONDNUM DB ?
STR3 DB ' IS '
ANS DB ?
STR4 DB ' $'
.CODE
MAIN PROC

MOV AX,@DATA
MOV DS,AX

MOV AH,2
MOV DL,3FH
INT 21H

MOV AH,1
INT 21H
MOV BL,AL
MOV FIRSTNUM,AL
INT 21H
MOV SECONDNUM,AL

ADD BL,AL
SUB BL,30H
MOV ANS,BL

MOV AH,9
LEA DX,STR1 ;VARIABLE PRINTING FIRST TO LAST
INT 21H

MOV AH,4CH
INT 21H

MAIN ENDP
END MAIN

0 nhận xét:

Đăng nhận xét