Discussion:
How to get pointer to class VMT in assembler block
(too old to reply)
Bishop
2017-02-19 21:42:20 UTC
Permalink
Raw Message
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
silvioprog
2017-02-20 05:30:26 UTC
Permalink
Raw Message
I need to get pointer to class VMT in assembler block. In pascal code this
can be done very simple, like Ptr := Pointer(SomeClass). But when i try in
assembler do like "MOV RAX, SomeClass" this make assembler syntax error. If
i try "LEA RAX, [SomeClass]" this compiled like "LEA RAX, [0]".
So, how get pointer to specefic class VMT in assembler block?
The assembler window (ctrl+alt+d) may help you to check what asm block fpc
generated for its pascal code, for example, in my target (64 bits) the
following asm block code was generated for a `ptr := pvmt(classtype)`:

...
unit1.pas:36 ptr := pvmt(classtype);
000000000045E7A1 488b45f0 mov -0x10(%rbp),%rax
000000000045E7A5 488b00 mov (%rax),%rax
000000000045E7A8 488945e0 mov %rax,-0x20(%rbp)
000000000045E7AC 488945e8 mov %rax,-0x18(%rbp)

and iirc the default asm syntax for my system (linux) is at&t.

hth

--
Silvio Clécio

Loading...