[fpc-devel] VMTOffset does not work in the built-in assembler for ARM

Fantomas fantomaspda at ya.ru
Sun Feb 15 00:43:02 CET 2009


Dear sirs!

I have encountered that the VMTOffset directive does not work in the built-in
assembler for CPU_TARGET=ARM (OS_TARGET=WINCE), but for i386 (Win32) it works OK
as it is described in Delphi documentation. I use the FP compiler of version
2.3.1 built from trunk.

Could you explain me, please, what I did wrong? Or VMTOffset is not applicable
to the ARM built-in assembler?
Thank you.



type
TSomeClass = class(TObject)
function DoIt:longint; virtual;
end;

var cls:TSomeClass;

function _vmthd_call:longint;
begin
  Result:=cls.DoIt;
end;



ARM assembler:

function _vmthd_call:longint; cdecl; assembler;
asm
    mov    r12,r13
    stmfd  r13!,{r11,r12,r14,r15}
    sub    r11,r12,#4

    ldr    r0,.L_cls
    ldr    r0,[r0]
    ldr    r1,[r0]

    ldr    r4,[r1,#80] -> No compilation errors

    ldr    r4,[r1,VMTOFFSET TSomeClass.DoIt] -> Error: invalid reference syntax

    mov    r14,r15
    mov    r15,r4

    ldmea  r11,{r11,r13,r15}          

.L_cls:
    .long cls
end;


I386 assembler. This is always compiled successfully:

{$ASMMODE INTEL}
function _vmthd_call(iIndex:integer):word; assembler;
asm
    MOV    EAX,DWORD PTR cls
    CALL   [EAX+VMTOFFSET TSomeClass.DoIt]
end;





More information about the fpc-devel mailing list