Re: QWORD PTR error on Intel Mac



Maybe... You need to state what assembler (or compiler) you're using.

From "Intel Mac", I could assume GAS for GCC (or GCC inline C assembly), but
I don't know for sure.


I use the XCode default compiler (GCC 4.0).
(XCode is the Apple free IDE)


Anyway, your starting code is MASM syntax:
FLD QWORD PTR [EDI]

For this code I used Visual C++ (Visual Studio .NET 2003)



I make this test:


int find;
float farr[3];
farr[0] = 1.24f;
farr[1] = 3.57f;
farr[2] = 0.0f;
find = &farr[0];
asm
{
MOV EDI, find
FLD [EDI+4]
FSTP [EDI+8]
}
printf("%7.3f\n", farr[2]);


The output is: 3.570 (OK)

If i change the two lines:
FLD [EDI+4]
FSTP [EDI+8]
with:
FLD WORD PTR [EDI+4]
FSTP WORD PTR [EDI+8]
or with:
FLD DWORD PTR [EDI+4]
FSTP DWORD PTR [EDI+8]
the results are the same: 3.570 !!!

Why?

WORD PTR is equal to DWORD PTR ???


I make this other test (I use double instead of float):

int dind;
double darr[3];
darr[0] = 1.24;
darr[1] = 3.57;
darr[2] = 0.0;
dind = &darr[0];
asm
{
MOV EDI, dind
FLD DWORD PTR [EDI+8]
FSTP DWORD PTR [EDI+16]
}
printf("%7.3f\n", darr[2]);

The output is: 3.570 (OK)

But if I change the two lines:
FLD DWORD PTR [EDI+8]
FSTP DWORD PTR [EDI+16]
with:
FLD WORD PTR [EDI+8]
FSTP WORD PTR [EDI+16]
or with:
FLD [EDI+8]
FSTP [EDI+16]
the result is wrong: 0.000


It is like DWORD PTR point to a 64 bit real number on GCC 4.0 for Mac,
but on Win to point to a 64 bit real number I have to use QWORD PTR !?!

All this sound strange to me.

.