Getting started in assembly

Moderators: None (Apply to moderate this forum)
Number of threads: 219
Number of posts: 577

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Averaging in assembly using floating point values Posted by justbrianr on 29 Nov 2010 at 9:10 PM
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




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.