[fpc-pascal] Inline assembly using absolute dword ptr

OBones obones at free.fr
Fri Apr 20 17:35:33 CEST 2012

OBones wrote:
> The function starts at line 26 so the errors are about "dword ptr" and 
> "abs qword ptr" inside the fs and gs square brackets
> What is wrong with my syntax? Is there another way to write it and get 
> it to work?
Ok, answering myself here, the syntax accepted by FPC is the following:

function MyGetCurrentThreadId: DWORD; assembler;
   {$IFDEF WIN32}
   push    ecx
   mov     ecx,dword ptr fs:[$18]
   mov     eax,dword ptr [ecx + $24]
   pop     ecx
   {$ENDIF WIN32}
   {$IFDEF WIN64}
   push    rcx
   mov     rcx,abs qword ptr gs:[$30]
   xor     rax,rax
   mov     eax,dword ptr [rcx + $48]
   pop     rcx
   {$ENDIF WIN64}

However, this gives a warning on line 36, the one with "abs qword ptr" :

RuntimeCodeUtils.pas(36,19) Warning: (7032) Calling an overload function 
in assembler

So it seems it thinks that abs is there for calling the "abs"  function 
while I want to specify absolute memory referencing and not relative 

Any hints?

More information about the fpc-pascal mailing list