[fpc-devel] registers used in function call, any rule?

Martin fpc at mfriebe.de
Wed Apr 27 20:07:03 CEST 2011

On 27/04/2011 19:03, Jonas Maebe wrote:
> On 27 Apr 2011, at 19:51, Martin wrote:
>> Not sure were I got my original info from... , but at current lazarus-ide (debugger) assumes that (on 64 bit) arguments (to fpc_raiseexceptions) are passed in RDI, RSI, RDX.
>> I thought some one had told me that this was some kind of standard and would always work? (I may be wrong...)
>> Now I just been running some code in the debugger 64 bit, win XP.
>> And the first arg was either in rax or rcx; see assembler below
>> Any ideas how to know what register to expect?
> Win64 uses a different ABI than all other x86-64 platforms.

So what is the correct order then?

RCX, R8, RDX ?
RCX, RDX, R8 ?

00000001000B1F92 4889c1                   mov    %rax,%rcx
00000001000B1F95 4989e8                   mov    %rbp,%r8
00000001000B1F98 488d15f6ffffff           lea    -0xa(%rip),%rdx        
# 0x1000b1f95 <CLASSES_TSTREAM_$__READBUFFER$formal$LONGINT+69>
00000001000B1F9F e88ccaf5ff               callq  0x10000ea30 

More information about the fpc-devel mailing list