[fpc-pascal] Inline assembly using absolute dword ptr

OBones obones at free.fr
Mon Apr 23 09:07:58 CEST 2012

Jonas Maebe wrote:
> On 20 Apr 2012, at 17:50, OBones wrote:
>> So there is a difference with Delphi's assembler where it defaults to relative indexing while FPC defaults to absolute in that context.
> What exactly do you mean by relative addressing in this context? RIP-relative? In FPC, you indeed have to explicitly mention the RIP register in your reference to get RIP-relative addressing.
What I mean is that under Delphi XE2 in x64 mode, if I type this:

rcx,qword ptr gs:[$30]

I get this generated code:


but if I type the "abs" keyword, I get this:


while if I do it in x86 mode, I get this :

mov     ecx,dword ptr fs:[$18]


so it seems that for Delphi XE2 in x64, the default mode, when no 
keyword is specified, is to use "relative" indexing which is definitely 
not what I want.
Freepascal, however, appears to use absolute indexing in all mode in 
this instance, which is fine by me, but something to keep in mind when 
porting the code.


More information about the fpc-pascal mailing list