Re: Kernel Calling Conventions
- From: "Rod Pemberton" <spamtrap@xxxxxxxxxx>
- Date: Thu, 23 Mar 2006 16:03:48 -0500
"Sprunk, Stephen" <spamtrap@xxxxxxxxxx> wrote in message
news:97C62702BB99A243BF1B3FED2FA19BEE0CE94C@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
"Rod Pemberton" <spamtrap@xxxxxxxxxx> wrote in messagea
news:dvksfo$bob$1@xxxxxxxxxxxxxxxxxxxx
"Kroll" <spamtrap@xxxxxxxxxx> wrote in message
news:1142802844.123840.209440@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Greetings all,
I was reading the "FreeBSD Assembly Language Programming" tutorial
(http://www.int80h.org/bsdasm/), when I came across something that
piqued my curiosity.
The C calling convention is touted as being more convenient, and
superior to the calling convention used by linux and microsoft of
passing arguments within registers. I was wondering if this is just
bias on the part of the writer or what.
What are the actual advantages of popping the arguments onto to the
stack as opposed to passing them via registers?
I don't think one is necessarily better than the other. For the C
language, I'd say that the C calling convention is best. But, for
assembly programming, I think passing in registers is the more
convenient.
If you're trying to design a one-size-fits-all calling convention, the
main
consideration is the number of GPRs. x86 only has 6 usable GPRs (5 for
PIC)
during a call, so if you pass in registers most of the time the callee
will
have to immediately spill them; you might as well let the caller spill
them
and improve OOO performance.
Actually, the number of GPR's is compiler specific too. GCC style compilers
use a register based stackframe consuming two registers: EBP and ESP.
However, OW doesn't use a register based stackframe. It uses the pop
immediate value of the RET instruction to pull unused arguments off the
stack.
Rod Pemberton
PS. I think you sent that across as HTML instead of plain text. I had to
manually correct the quoting...
.
- References:
- Re: Kernel Calling Conventions
- From: Sprunk, Stephen
- Re: Kernel Calling Conventions
- Prev by Date: Re: ld dynamic linker x86-64 ?!
- Next by Date: Re: Recommendations for Self-Instruction?
- Previous by thread: Re: Kernel Calling Conventions
- Next by thread: ld dynamic linker x86-64 ?!
- Index(es):
Relevant Pages
|