I have created this code, but now I need the create new prgram that repeats the same steps three times, using loop. Clear the screen after each loop iteration. ???
integer_count = 3
.data
promptuser byte "Enter a two integers: ", 0
sumOf byte "The sum of the integers is: ", 0
array dword integer_count dup (?)
.code
main proc
call clrscr
mov dh, 15
mov dl, 25
call gotoxy
call crlf
mov esi, offset array
mov ecx, integer_count
call promptforintegers
call arraysum
call displaysum
call dumpregs
exit
main ENDP
;-------------------------------------------------------------------
promptforintegers proc uses ecx edx esi
;Prompts the user for an arbitrary number of integers and inserts the
;integers into an array.
;Receives: ESI points to the array, ECX = array size
;Returns: nothing
;------------------------------------------------------------------
mov edx, offset promptuser ; "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
;Calculates the sum of an array of 32-bit integers.
;Receives: ESI prints to the array, ECX = number
;of array elements
;Returns: EAX = sum of the array elements
;------------------------------------------------------------------
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
call dumpregs
Loop L1 ; repeat for array size
ret ; sum is in eax
arraysum endp
;------------------------------------------------------------------
displaysum proc uses edx
;
;Displays the sum on the screen
;Receives: eax = the sum
;Returns: nothing
;------------------------------------------------------------------
mov edx, offset sumOf ; "The sum of the ..."
call writestring
call writeint ; display eax
call crlf
ret
displaysum endp
end main