156k views
1 vote
Write an LC-3 assembly language program to read in a two-digit decimal number whose digits add up to less than 10 and display the sum of those digits in the next line.

Sample execution (user input underlined) : Please enter a two-digit decimal number > 27. The sum of the digits = 9

1 Answer

2 votes

Answer:

Step-by-step explanation:

.MODEL SMALL

.STACK 100H

.DATA

STR1 DB 0AH,0DH, 'THE SUM OF TWO DIGITS PRENT IN THE GIVEN NUMBER'

FNUM DB ?

STR2 DB ' AND '

SNUM DB ?

STR3 DB ' IS '

ANS DB ?

STR4 DB ' $'

.CODE

MAIN PROC

MOV AX, "at" DATA PLEASE NOTE: your "at" need to be in symbol

MOV DS,AX It is because this text editor who allow the sub-

mission of this answer if i use the symbol format

MOV AH,2 that is why put it in bold and parenthesis

MOV DL,3FH

INT 21H

MOV AH,1

INT 21H

MOV BL,AL

MOV FNUM,AL

INT 21H

MOV SNUM,AL

ADD BL,AL

SUB BL,30H

MOV ANS,BL

MOV AH,9

LEA DX,STR1

INT 21H

MOV AH,4CH

INT 21H

MAIN ENDP

END MAIN

User Ben Konyi
by
4.3k points