I need help on a Masm32 problem: Summation Program Modify the summation program
ID: 3535022 • Letter: I
Question
I need help on a Masm32 problem: Summation Program
Modify the summation program in section 5.6.1 of Assembly Language for x86 Processors as follows: Select an aarray size using a sonstant:
ARRAY_SIZE = 20
array DWORD ARRAY_SIZE DUP (?)
Write a new procedure that prompts the user for the number of integers to be processed. Pass the same value to the PromptForIntegers procedure. For Example,
How many integers will be added? 5
thias is what i have so far but i can't get it to run:
TITLE Integer Summation Program (Sum2.asm)
INCLUDE Irvine32.inc
INTEGER_COUNT = 3
ARRAY_SIZE = 20
.data
str3 BYTE "How many integers will be added? ",0
str1 BYTE "Enter a signed integer: ",0
str2 BYTE "The sum of the integers is: ",0
array DWORD INTEGER_COUNT DUP(?)
array DWORD ARRAY_SIZE DUP(?)
.code
main PROC
call Clrscr
mov esi,OFFSET array
call promptMes
mov ecx,eax
call PromptForIntegers
call ArraySum
call DisplaySum
exit
main ENDP
promptMes proc uses ecx edx esi
mov edx,offset str3
mov esi,offset array
call writestring ;display string
call readint ;read integer into eax
call crlf ;go to nest output line
ret
promptMes endp
PromptForIntegers PROC USES ecx edx esi
mov edx,OFFSET str1 ; "Enter a signed integer"
L1: call WriteString ; display string
call ReadInt ; read integer into EAX
call Crlf ; go to next output line
mov [esi],eax ; store in array
add esi,TYPE DWORD ; next integer
loop L1
ret
PromptForIntegers ENDP
ArraySum PROC USES esi ecx
mov eax,0 ; set the sum to zero
L1: add eax,[esi] ; add each integer to sum
add esi,TYPE DWORD ; point to next integer
loop L1 ; repeat for array size
ret ; sum is in EAX
ArraySum ENDP
DisplaySum PROC USES edx
mov edx,OFFSET str2 ; "The sum of the..."
call WriteString
call WriteInt ; display EAX
call Crlf
ret
DisplaySum ENDP
END main
Thanks for the help.
Will rate if answered correctly.
Explanation / Answer
This question lacks in details.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.