I need some assistance in my program: I suppose to select an array size:

array_size = 20
array dword array_size dup(?)

And, create a new procedure that prompts the user for the number of integers to be processed, and pass the same value to the promptForIntegers procedure.

How many integers will be added? 5

My problems is that my counter continue to iterates infinite times, and my question is how and where do I take the user input above (5) and pass the counter and (5) to procedure promptForIntegers?

INCLUDE Irvine32.inc

 array_size = 10
 prompt1 byte "How many integers will be added?", 0
 prompt2 byte "Enter a signed integer: ", 0
 prompt3 byte "The sum of the integers is: ", 0
 array dword array_size dup(?)

 main proc
		call clrscr
		mov ecx,eax
		call promptMes
		call arraysum
		call displaysum
main endp

promptMes proc uses ecx edx esi
		mov edx,offset prompt1
		mov esi,offset array
		call writestring		
		call readint			
		call crlf				
		call promptforintegers
promptMes endp

promptforintegers proc uses ecx edx esi

	mov edx,offset prompt2		
	l1: call writestring		
	call readint			
	call crlf				
	mov [esi], ax				
	add esi,type word		
		loop l1
promptforintegers endp

arraysum proc uses esi ecx

	mov eax, 0						
	l1: add eax,[esi]				
	add esi,type dword				
	loop l1			
arraysum endp

	mov edx, offset prompt3			
	call writestring
	call writeint				
	call crlf
displaysum endp
end main

Thanks, I got it operating! Now,I want to use a conditional structure to validate their entry. Like this, when the user enter a number greater than n , I will display a error message and then I will allow them n time retry before the program ends. I sorry about this but my instructor did not lecture on this at all (final time)... intro to assembly language... Thanks for you prompt responds...

This article has been dead for over six months. Start a new discussion instead.