Hello all, I am having some trouble with my assembly code...still kind of new, but here it goes...
The assignment is to desing an assembly program that uses a dialog box to prompt the user for a number. These numbers will be stored in an array. There will be an output message that shows the following: sum of numbers entered, how many numbers were entered(not counting the -9999 to end the program), the aerage of the numbers, and the count of array entries that are greater that or equal to the average value. All help is appreciated!
Here is my code so far:
`.586
.MODEL FLAT
INCLUDE io.h ; header file for input/output
.STACK 4096
.DATA
numArray DWORD ?
numElts DWORD 100
num DWORD ?
prompt BYTE "Enter a number", 0
string BYTE 40 DUP (?)
resultLbl BYTE "Results", 0
sum BYTE 11 DUP(?), " is the sum.", 0dh, 0ah
numEntered BYTE 11 DUP(?), " numbers were entered."
avg BYTE 11 DUP(?), " is the average."
count BYTE 11 DUP(?), " is the number of entries that are >= the average."
.CODE
_MainProc PROC
mov edx, -9999
mov eax, 0 ; sum := 0
lea ebx, numArray ; get address of nbrArray
LOOP1: input prompt, string, 40 ; read ASCII characters
atod string ; convert to integer
mov num, eax ; store in memory
mov ecx, numElts ; count := nbrElts
jedx QUIT ; quit if -9999
add eax, [ebx] ; add number to sum
add ebx, 4 ; get address of next array elt
add ecx, 1 ; add one for count
loop LOOP1 ; repeat nbrElts times
cdq ; extend sum to quadword
idiv numElts ; calculate average
output resultLbl, sum, avg, numEntered, count
QUIT: mov eax, 0 ; exit with return code 0
ret
_MainProc ENDP
END ; end of source code`