Re: Kernel Calling Conventions




"Sprunk, Stephen" <spamtrap@xxxxxxxxxx> wrote in message
news:97C62702BB99A243BF1B3FED2FA19BEE0CE94C@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
"Rod Pemberton" <spamtrap@xxxxxxxxxx> wrote in message
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
a
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...



.



Relevant Pages

  • Re: Kernel Calling Conventions
    ... The C calling convention is touted as being more convenient, ... passing arguments within registers. ... calling convention is to use registers and not the stack. ... over the DJGPP GCC based compiler, is due to the fact that the OW ...
    (comp.lang.asm.x86)
  • Re: calling procedure from asm
    ... since the default calling convention is ... I use SSE instructions to calculate some ... As long as you're not accessing the MMX registers the SSE ...
    (borland.public.delphi.language.basm)
  • Re: x86-64 and calling conventions
    ... and there is no particular relation between the registers and the ... but is in the process of writing a compiler in Ruby (currently ... to the calling convention and just hiding them to the users of your ... but it'd result in function signatures that would be ...
    (comp.compilers)
  • Re: Calling conventions
    ... simulator had the calling convention that registers $t0-$t9 were ... If the SPIM simulator is strictly an instruction set simulator then it shouldn't impose any particular use of the registers. ... If you use a compiler, the compiler and library designers decide how to save context within the context of their compiler and library ...
    (comp.arch.embedded)