[fpc-pascal] Inline assembly using absolute dword ptr
OBones
obones at free.fr
Fri Apr 20 17:27:01 CEST 2012
Hello,
I'm trying to compile the following code under FreePascal 2.6.0 :
function MyGetCurrentThreadId: DWORD; assembler;
asm
{$IFDEF WIN32}
push ecx
mov ecx,fs:[dword ptr $18]
mov eax,dword ptr [ecx + $24]
pop ecx
{$ENDIF WIN32}
{$IFDEF WIN64}
push rcx
mov rcx,gs:[abs qword ptr $30]
xor rax,rax
mov eax,dword ptr [rcx + $48]
pop rcx
{$ENDIF WIN64}
end;
It compiles just fine under Delphi XE2 but Freepascal 2.6.0 cannot
compile it either for Win32 or Win64.
For Win32, I use those command line arguments
-vewhq -Rintel -FEi386-win32 -Mdelphi -Twin32
and I get these errors
RuntimeCodeUtils.pas(30,19) Error: (7014) Invalid reference syntax
RuntimeCodeUtils.pas(43,4) Fatal: (10026) There were 1 errors compiling
module, stopping
Fatal: (1018) Compilation aborted
For Win64, I use those command line arguments
-vewhq -Rintel -FEx86_64-win64 -Mdelphi -Twin64
and I get these errors
RuntimeCodeUtils.pas(36,23) Error: (7021) Invalid operand type
RuntimeCodeUtils.pas(36,23) Warning: (7032) Calling an overload function
in assembler
RuntimeCodeUtils.pas(36,23) Error: (7014) Invalid reference syntax
RuntimeCodeUtils.pas(43,4) Fatal: (10026) There were 2 errors compiling
module, stopping
Fatal: (1018) Compilation aborted
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?
Thanks in advance.
More information about the fpc-pascal
mailing list