Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-04

registers used in function call, any rule?

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin

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?

00000001000B1F6B ff90f8000000 callq *0xf8(%rax) 00000001000B1F71 39d8 cmp %ebx,%eax 00000001000B1F73 7d2f jge 0x1000b1fa4 <CLASSES_TSTREAM_$__READBUFFER$formal$LONGINT+84>
00000001000B1F75 4c8b059c5f9d00 mov
0x9d5f9c(%rip),%r8 # 0x100a87f18 <RESSTR_RTLCONSTS_SREADERROR+8> 00000001000B1F7C 488d153d499c00 lea
0x9c493d(%rip),%rdx # 0x100a768c0 <VMT_CLASSES_EREADERROR> 00000001000B1F83 48b90000000000000000 movabs $0x0,%rcx 00000001000B1F8D e8ee9df7ff callq 0x10002bd80 <SYSUTILS_EXCEPTION_$__CREATE$ANSISTRING$$EXCEPTION> 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 <fpc_raiseexception>

Reply by email

Jonas Maebe
to Martin
Martin wrote 9 lines
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.

Jonas

Reply by email

Martin
to Jonas Maebe
Jonas Maebe wrote 13 lines
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 <fpc_raiseexception>

Reply by email

Martin
to Jonas Maebe

Thanks,

Sorry, had hoped you would by any change happen to know... should have figured if you didn't say in your first mail... my bad

Martin

Jonas Maebe wrote 15 lines
On 27 Apr 2011, at 20:07, Martin wrote: > On 27/04/2011 19:03, Jonas Maebe wrote: >> Win64 uses a different ABI than all other x86-64 platforms. > So what is the correct order then? http://www.google.com/search?q=win64+abi -> first link: The Win64 ABI is described at: http://www.nasm.us/links/win64abi -> click on "Register Usage" -> http://msdn.microsoft.com/en-us/library/9z1stfyw.aspx Jonas_______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email