www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - asm problems and documentation errors

I have three inline assembler problems.

First, a documentation error.
On the inline asm page, under 'asmTypePrefix' it lists 'extended ptr'.
I think this should be 'real ptr' (which works).
I noticed that 'qword ptr' also works, though it is not documented.
It seems as though no type checking is done for integer operations, see below.
But that's a minor issue.

Secondly, I'm trying to understand the format of complex numbers. It has to be
the same as for C99, right? Can complex values be returned on the stack, or do
they have to be stored into a creal? (For that matter, are ordinary floats
returned on the stack?)

Thirdly, I can't work out the syntax for accessing the imaginary part of a
complex number.
The line:
fld albatross.im;
generates the error:
bad type/size of operands 'cast(ireal)(albatross)'
which was not what I was expecting.


creal icefloe()
creal albatross=5+6i;
real walrus;
asm {
fld walrus; // OK, it's simple.
mov EBX, [albatross];
mov EAX, dword ptr [EBX]; // works as expected
mov EAX, real ptr [EBX];    // huh? should be an error
fld real ptr [EBX]; // this works
fld albatross.im;  // why doesn't this work?
fld creal.im[albatross]; // this won't work either
Jul 31 2005