(Simple Addition)(2) Use the solution program from the preceding exercise as a s
ID: 3645202 • Letter: #
Question
(Simple Addition)(2)Use the solution program from the preceding exercise as a starting point. Let this new program repeat the same steps three times, using a loop. Clear the screen after each loop iteration.
INCLUDE Irvine32.inc
.data
input1stIntMsg BYTE "Input the 1st integer: ",0
input2ndIntMsg BYTE "Input the 2nd integer: ",0
outputSumMsg BYTE "The sum of the two integers: ",0
num1 DWORD ?
num2 DWORD ?
sum DWORD ?
.code
main PROC
call Clrscr ; clear screen
; read the first number
mov dl, 20 ; set the column
mov dh, 11 ; set the row
call Gotoxy ; move the cursor to near the center
; output the prompt message
mov edx,OFFSET input1stIntMsg
call WriteString
call ReadInt ; read integer
mov num1, eax ; store the value
; read the second number
mov dl, 20 ; set the column
mov dh, 12 ; set the row
call Gotoxy ; move the cursor to near the center
; output the prompt message
mov edx,OFFSET input2ndIntMsg
call WriteString
call ReadInt ; read integer
mov num2, eax ; store the value
; compute the sum
mov eax, num2
add eax, num1
mov sum, eax
; output result
mov dl, 20 ; set the column
mov dh, 13 ; set the row
call Gotoxy ; move the cursor to near the center
mov edx, OFFSET outputSumMsg
call WriteString
mov eax, sum
call WriteInt
exit
main ENDP
END main
Explanation / Answer
.code main Clrscr mov dh,10 ;row 10 mov dl,20 ;column 20 call Gotoxy ;locate cursor PromptForIntegers WriteString ;display string ReadInt ;input integer ArraySum WriteString ;display string WriteInt ;display integer DisplaySum ENDP END main
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.