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`

Did some more troubleshooting, and changed a few things...this is what I have now....still need help guys...its due tonight. Again, all help is appreciated greatly!!!

.DATA
numArray       DWORD   ?
numElts     DWORD   100
num         DWORD   ?
exitNum     DWORD   -9999
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     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
            cmp     exitNum, eax
            je       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
            mov     count, ecx
            mov     sum, eax
            mov     avg, ebx

            output     resultLbl, sum, avg, numEntered, count
QUIT:       mov        eax, 0                    ; exit with return code 0
            ret

Have some more code...I'm sorry to keep posting, but I am really at a roadblock! It compiles, but now I cannot output anything. Here it is:

            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
            cmp     exitNum, eax
            je      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
            dtoa    avg, ebx                    ; convert to ASCII characters
            dtoa    count, ecx
            dtoa    sum, eax

QUIT:             
            output resultLbl, sum, avg, count
            ret
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.