On Friday, 27 May 2016 at 10:00:40 UTC, Era Scarecrow wrote:
On Friday, 27 May 2016 at 09:51:56 UTC, rikki cattermole wrote:
struct Foo {
  int x;

  void foobar() {
    asm {
      mov EAX, this;
      inc [EAX+Foo.x.offsetof];
    }
  }
}

You have to reference the field via a register.

This is good progress. Using the assembler doesn't have many documentation examples of how to do things

 Hmmm actually this is incorrect...

void main() {
  import std.stdio;

  Foo foo = Foo(-1);
  writeln(foo.x);
  foo.foobar;
  writeln(foo.x);
}

-1
-256

It's assuming a byte obviously for the size. So this is the correct instruction:

  inc dword ptr [EAX+Foo.x.offsetof];

However trying it with a long and a qword shows it reverts to a byte again, meaning 64 bit instructions are inaccessible.

Reply via email to