Averaging in assembly using floating point values - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Averaging in assembly using floating point values

I have to get average of 6 grades. Somehow I getting a wrong answer

Here's how I'm passing my values in C++. Since it's an assignment I can't change my C++ code.

extern "C" double Average (long [6]);

and then my assembly procedure looks like this:

_Average proc

finit
mov ecx, 6 ; number of elements
mov ebx, [esp + 4] ; address of the array
fldz

L1:
fld REAL4 PTR [ebx] ; get elements of array
fadd
add ebx, 4

loop L1
fdiv DWORD PTR [esp + 4]

fwait

ret

_Average endp

Sign In or Register to comment.