News for hackers. Stuff that matters.
Re:32-bit x86 Position Independent Code – It's That Bad by mappu on Wednesday April 15, 2015 @02:11AM (#9379165)
>Why does Linux pass arguments in registers instead of using the stack?

It's a convention. Depending on your architecture, compiler and API, it uses the stack in a lot of cases (cdecl/stdcall on i386). Linux on AMD64 always uses the SYSV ABI which uses registers as much as possible (i'm assuming for performance reasons, since 'fastcall' does the same on i386).

Re:32-bit x86 Position Independent Code – It's That Bad by raverbashing on Wednesday April 15, 2015 @05:58AM (#9379890)
I didn't know that was the name of it, interesting, though it sounds like an Anachronism

http://en.wikipedia.org/wiki/X86_calling_conventions#System_...

Re:32-bit x86 Position Independent Code – It's That Bad by gwu78 on Wednesday April 15, 2015 @10:46AM (#9381298)
"It's a convention."

Does Minix use that convention? How about BSD?

Re:32-bit x86 Position Independent Code – It's That Bad by icebraining on Wednesday April 15, 2015 @11:41AM (#9381686)
"The calling convention of the System V AMD64 ABI is followed on Solaris, Linux, FreeBSD, Mac OS X, and other UNIX-like or POSIX-compliant operating systems."

http://en.wikipedia.org/wiki/X86_calling_conventions#System_...

Re:32-bit x86 Position Independent Code – It's That Bad by gwu78 on Wednesday April 15, 2015 @10:21PM (#9385552)
int80h.org

Anyway, the original question was _why_ does Linux use registers to pass arguments. Arguments can be passed on the stack, but Linux chose to use registers. Why this choice over the other option?

Do you know the answer?

Just curious.

Re:32-bit x86 Position Independent Code – It's That Bad by icebraining on Thursday April 16, 2015 @03:58AM (#9386501)
It's because in theory, it's faster to copy the values to registers than to have to push them all to the stack and then have the callee pop them. At least that was the thought behind Microsoft's __fastcall, which was their original version of a calling convention using registers, though in that case it seems the benchmarks aren't conclusively in support of the theory.