Issues using the in-line assembler
Basile B.
b2.temp at gmx.com
Thu Apr 5 04:48:02 UTC 2018
On Wednesday, 4 April 2018 at 21:00:44 UTC, solidstate1991 wrote:
> I have this code:
> asm @nogc{
> movq XMM0, xy;
> paddd XMM0, sXY; // xy + sXY
> movq XMM3, xy0;
> psubd XMM0, XMM3; // xy + sXY - x0y0
> movq XMM1, ac;
> movq XMM2, bd;
> pmuludq XMM1, XMM0; // (ac * (xy + sXY - x0y0))
> psrlq XMM1, 16; // (ac * (xy + sXY - x0y0))>>16
> pmuludq XMM2, XMM0; // (bd * (xy + sXY - x0y0))
> psrlq XMM2, 16; // (bd * (xy + sXY - x0y0))>>16
> paddq XMM1, XMM2; // (bd * (xy + sXY - x0y0))>>16 * (ac * (xy
> + sXY - x0y0))>>16
> punpckldq XMM3, XMM7;
> paddq XMM1, XMM3; // (bd * (xy + sXY - x0y0))>>16 * (ac * (xy
> + sXY - x0y0))>>16 + x0y0
> movups XMM2, XMM1; // Convert 64 bit vectors into 32 bit ones
> psrldq XMM2, 4;
> por XMM2, XMM1;
> movq result, XMM2;
> }
> I'm getting "bad type/size of operand 'movq'" error on xy0, ac,
> and bd when I try to compile it. All of the values are the type
> of int[2], xy is function parameter, sXY is created locally.
> How can I fix it?
The "this" seems to be in R11, so you have to apply the asm
syntax for accessing the members using
<Type>.offsetof.<member>[R11], example:
```
class Foo
{
double a = 123456;
extern(D) double foo()
{
asm
{
naked;
movq XMM0, Foo.a.offsetof[R11];
ret;
}
}
}
void main()
{
import std.stdio;
(new Foo).foo(0,0).writeln;
}
```
However i cant find any specification saying that R11 is "this".
With a free function just pass the instance as param and replace
R11 by the register where the instance is passed.
More information about the Digitalmars-d-learn
mailing list