access member variables within asm

Kai Nacke via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Tue May 26 09:44:01 PDT 2015


Hi!

That's really a deviation from dmd. Please file an issue for it: 
https://github.com/ldc-developers/ldc/issues

Please not that DMD-style inline assembler is not the best 
solution for ldc. If you need maximum performance than you should 
think about creating a solution with ldc style inline assembler.

Regards,
Kai

On Monday, 18 May 2015 at 14:22:29 UTC, this.getName() wrote:
> Hi,
> following simple code works well with dmd but LDC won't let me 
> access member variables of a struct that way. How does is work? 
> Is there nice method compatible with both LDC and DMD?
>
> thanks in advance
>
> module app.d;
>
> import std.stdio;
>
> struct test {
>         uint a = 42;
>         uint b = 7;
>
>         uint getA() {
>                 uint temp;
>                 asm {
>                         mov RBX, this;
>                         mov EAX, a[RBX];
>                         mov temp, EAX;
>                 }
>                 return temp;
>         }
> }
>
> public static void main() {
>         writeln("asm 'this' test");
>         test t;
>         writeln("test.getA(): ", t.getA());
>         assert(t.getA() == t.a, "getA() failed");
> }



More information about the digitalmars-d-ldc mailing list