Re: Kernel Calling Conventions



"Robert Redelmeier" <redelm@xxxxxxxxxxxxxxx> wrote in message
news:byrTf.61766$dW3.56969@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Kroll <spamtrap@xxxxxxxxxx> wrote in part:
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.

IMHO, "bias" is too mild a word :)
....
The main advantage of stack params is that many more
can be passed.

Typically, calling conventions are designed so that the first N
parameters
are passed in registers, and if the call exceeds that the remainder are
put
on the stack. N is typically around half the number of GPRs; x86 ABIs
set
N=0 in most cases since there are so few to spare.

IIRC, the AMD64 ABI has an interesting quirk that the call stack has
space
reserved for the register parameters so that the called code has an easy

place to spill them if needed.

S

--
Stephen Sprunk "Stupid people surround themselves with smart
CCIE #3723 people. Smart people surround themselves with
K5SSS smart people who disagree with them." --Aaron Sorkin


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: Kernel Calling Conventions
    ... The C calling convention is touted as being more convenient, ... passing arguments within registers. ... stack as opposed to passing them via registers? ... by the C compiler or tell the C compiler to "reoptimize" your assembly code. ...
    (comp.lang.asm.x86)
  • Re: va_args (va_start, va_end, va_list ) souce?
    ... They're macros, not functions. ... registers, which will be on the stack. ... some platforms use a different calling convention for variadic ...
    (comp.arch.embedded)
  • Re: Kernel Calling Conventions
    ... The C calling convention is touted as being more convenient, ... passing arguments within registers. ... None have mentioned that passing arguments on the stack allows ...
    (comp.lang.asm.x86)
  • Re: StdCall vs. CDecl
    ... __cdecl means that the caller needs to remove the args. ... caller to clean up the stack, while the caller will expect the function to ... why does our VB.NET code work well when the calling convention ...
    (microsoft.public.dotnet.framework.interop)