Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2017-02

How to get pointer to class VMT in assembler block

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog
to Bishop
Bishop wrote 7 lines
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

Reply by email