RFC: if_ndis on amd64
Ville-Pertti Keinonen
will at exomi.com
Wed Jan 12 23:16:07 PST 2005
On Wed, 2005-01-12 at 15:33 -0800, David O'Brien wrote:
> What are "calling conventions that everyone else uses"?? Such things
> really don't exist as x86 CPU's don't force a particular way. It is up
> to the compiler writer to do what he wants.
Note that I didn't even try to claim "standard" calling conventions;
however AFAIK all of the released operating systems that run on amd64
(*BSD, Linux, Solaris) use the same C ABI (SysV (ELF) ABI).
Often at least the basic C calling conventions are compatible across
ABIs.
> Both the AMD64 ELF and AMD64 PE (mswin) ABI's specify that the first X
> parameters are passed in registers (beyond that on the stack). So both
> ELF (ie, FreeBSD) and MSwin passes parameters differently on 32-bit
> "i386" vs. 64-bit AMD64.
The different i386 conventions are at least partly to historical
reasons. Since 64-bit mode is inevitably incompatible with 32-bit mode,
I was hoping 64-bit mode would be somewhat more consistent.
Anyhow, having to create wrappers isn't that bad, and should be possible
to be coerced to work correctly. The varargs kludge I used should be
possible to eliminate by transforming the arguments into a va_list
instead of trying to preserve it as a varargs call. Something like:
ENTRY(sprintf_x64)
subq $40,%rsp
mov %rdi,32(%rsp)
mov %rsi,24(%rsp)
mov %r8,40+8+16(%rsp)
mov %r9,40+8+24(%rsp)
movl $48,(%rsp)
movl $0,4(%rsp)
lea 40+8+16(%rsp),%rax
mov %rax,8(%rsp)
mov %rax,16(%rsp)
mov %rcx,%rdi
mov %rdx,%rsi
mov %rsp,%rdx
call vsprintf
mov 32(%rsp),%rdi
mov 24(%rsp),%rsi
addq $40,%rsp
ret
More information about the freebsd-amd64
mailing list