access member variables within asm

this.getName() via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Mon May 18 07:22:28 PDT 2015


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