Re: Kernel Calling Conventions
- From: "Rod Pemberton" <spamtrap@xxxxxxxxxx>
- Date: Sun, 19 Mar 2006 19:20:18 -0500
"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. Leaving
them on the stack doesn't require you to save any registers which may be an
advantage. Also, you can always access data on the stack via the stack
pointer. But, if you're doing anything other than an extremely simple
operation on the data, you'll want to move them off the stack and into to
registers for speed.
When programming in C, one does not usually have direct access to the
registers. And, when you do, you can't usually tell which ones are in use
by the C compiler or tell the C compiler to "reoptimize" your assembly code.
Also, a large amount of the speed that OpenWatcom compiler has over the
DJGPP GCC based compiler, is due to the fact that the OW compiler makes
heavy use of the registers, for both it's register and stack calling
conventions. DJGPP, on the other hand, is heavy on stack usage, makes poor
use of the registers, and frequently uses low code density instructions. I
think it does the latter on the assumption that faster instructions are
faster without considering the effects of code bloat on the reloading of the
caches.
Rod Pemberton
.
- References:
- Kernel Calling Conventions
- From: Kroll
- Kernel Calling Conventions
- Prev by Date: ld dynamic linker x86-64 ?!
- Next by Date: Kernel Calling Conventions
- Previous by thread: Kernel Calling Conventions
- Next by thread: Kernel Calling Conventions
- Index(es):
Relevant Pages
|