unusual behaviour in delphi assembly block -


i running weird behaviour delphi's inline assembly, demonstrated in short , simple program:

program test;  {$apptype console}  uses     sysutils;  type     tasdf = class     public         int: integer;     end;      tblah = class     public         asdf: tasdf;          constructor create(a: tasdf);          procedure test;     end;  constructor tblah.create(a: tasdf); begin     asdf := a; end;  procedure tblah.test; begin     asm         mov eax, [asdf]     end; end;  var     asdf: tasdf;     blah: tblah;  begin     asdf := tasdf.create;      blah := tblah.create(asdf);      blah.test;      readln; end. 

it's sake of example (moving [asdf] eax doesn't much, works example). if @ assembly program, you'll see that

mov eax, [asdf] 

has been turned into

mov eax, ds:[4] 

(as represented ollydbg) crashes. however, if this:

var     temp: tasdf; begin     temp := asdf;      asm         int 3;         mov eax, [temp];     end; 

it changes mov eax, [ebp-4] works. why this? i'm working c++ , i'm used using instance vars that, may i'm using instance variables wrong.

edit: yep, it. changing mov eax, [asdf] mov eax, [self.asdf] fixes problem. sorry that.

a method receives self pointer in eax register. have use value base value accessing object. code like:

mov ebx, tblah[eax].asdf 

see http://www.delphi3000.com/articles/article_3770.asp example.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -