[fpc-devel] How to get pointer to class VMT in assembler block

silvioprog silvioprog at gmail.com
Mon Feb 20 06:30:26 CET 2017

On Sun, Feb 19, 2017 at 6:42 PM, Bishop <cat_shtaer at rambler.ru> wrote:

> 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.


Silvio Cl├ęcio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20170220/d699bd0e/attachment.html>

More information about the fpc-devel mailing list