I am coding a procedure in ASM that does some calcs with real numbers.
At the moment I use DQ as parameter data type and I am wondering if this is correct if in C I declare parameter as float. Doesn't REAL8 equal QWORD? Is it what float is? or I should use REAL4 or REAL10 instead?

Also, how should I return result (also float) ??
Posted on 2002-02-06 14:14:39 by Milos
A float in C is a "df" or "real4" in asm.
A double in C is a "dq" or "real8" in asm.

The extended (real10) is "double double" iirc.

Return value depends on compiler... I think visual C++ expects
the return value as ST(0) .
Posted on 2002-02-06 14:17:06 by f0dder
Float is usually REAL4, double is REAL8, and long double is TBYTE/REAL10. Some C compilers return floats on the top of the FPU stack, other actually store the value on the stack().

Edit: f0dder beat me by seconds. ;)
Posted on 2002-02-06 14:17:28 by bitRAKE
I was a bit wrong though it is "long double" and not "double double" :)
Posted on 2002-02-06 14:23:13 by f0dder
Thanks on these fast replies! :D
Posted on 2002-02-06 15:03:43 by Milos
For this:

Doesn't REAL8 equal QWORD?


Yes and No. It is the same size but consider these two statments:



QuadInt QWORD 67
QuadReal REAL8 67.0


QuadInt will be inialized to 67 in binary by masm. But QuadReal has to have the decimal point suffix because it will be initialized to 67.0's (Floating Point).

So if you had in a program:


.DATA
cConstant QWORD 100

.CODE
GetPercent PROC

fdiv cConstant



You would get some very funny results indeed.


This is the same for REAL4/DWORD, REAL8/QWORD and REAL10/TBYTE.
Posted on 2002-02-07 17:11:29 by huh