Re: syscall assembly

2000-12-19 Thread David O'Brien
On Sat, Dec 16, 2000 at 12:13:32PM -0800, Bakul Shah wrote: May be people who know more about gcc will explain this better but I will speculate in any case! Assuming that 16 ... But I still question this optimization. Are there any stats on whether this 16 byte aligning improves

Re: syscall assembly

2000-12-16 Thread Bakul Shah
Marc sent me this: pushl %ebp movl %esp,%ebp subl $8,%esp This might not be of interest to the rest of the mailing list but what is the purpose of the subl instruction used before calling functions? Is that where the return value is retrieved

syscall assembly

2000-12-13 Thread Marc Tardif
Considering the following C code: #include fcntl.h int main() { open("file", O_RDONLY); return 0; } compiled with gcc -S -O2, the following assembly code is generated: main: pushl %ebp movl %esp,%ebp subl $8,%esp addl $-8,%esp pushl $0 pushl

Re: syscall assembly

2000-12-13 Thread Alfred Perlstein
* Marc Tardif [EMAIL PROTECTED] [001213 13:30] wrote: Considering the following C code: #include fcntl.h int main() { open("file", O_RDONLY); return 0; } compiled with gcc -S -O2, the following assembly code is generated: main: pushl %ebp movl %esp,%ebp

Re: syscall assembly

2000-12-13 Thread Marc Tardif
On Wed, 13 Dec 2000, Alfred Perlstein wrote: * Marc Tardif [EMAIL PROTECTED] [001213 13:30] wrote: [ snip ] subl $8,%esp addl $-8,%esp pushl $0 pushl $.LC0 call open FreeBSD passes syscall args on the stack, Linux uses registers. So why is

Re: syscall assembly

2000-12-13 Thread Alfred Perlstein
David, can you look at this? #include fcntl.h int foo() { open("file", O_RDONLY); return 0; } int main() { int x; x = foo(); return 0; } results in: foo: pushl %ebp movl %esp,%ebp subl $8,%esp addl $-8,%esp pushl $0 pushl $.LC0

Re: syscall assembly

2000-12-13 Thread Iain Templeton
On Wed, 13 Dec 2000, Alfred Perlstein wrote: David, can you look at this? #include fcntl.h int foo() { open("file", O_RDONLY); return 0; } int main() { int x; x = foo(); return 0; } results in: foo: pushl %ebp movl %esp,%ebp subl $8,%esp

Re: syscall assembly

2000-12-13 Thread Warner Losh
In message [EMAIL PROTECTED] Marc Tardif writes: : So why is %esp displaced by 16 bytes when only 8 bytes : are necessary (4 for $0 and 4 for $.LC0)? And couldn't : the compiler use a single instruction such as : subl $16,%esp or addl $-16,%esp? Are two instructions : used for pipelining

Re: syscall assembly

2000-12-13 Thread Marc Tardif
On Thu, 14 Dec 2000, Iain Templeton wrote: On Wed, 13 Dec 2000, Alfred Perlstein wrote: subl $8,%esp addl $-8,%esp pushl $0 pushl $.LC0 call open why the subl then addl? Well, as a thoroughly rough guess, the subl is probably to create

Re: syscall assembly

2000-12-13 Thread Drew Eckhardt
In message [EMAIL PROTECTED], [EMAIL PROTECTED] writes: In message [EMAIL PROTECTED] Marc Tar dif writes: : So why is %esp displaced by 16 bytes when only 8 bytes : are necessary (4 for $0 and 4 for $.LC0)? And couldn't : the compiler use a single instruction such as : subl $16,%esp or addl

Re: syscall assembly

2000-12-13 Thread Drew Eckhardt
In message [EMAIL PROTECTED], intmktg@ CAM.ORG writes: Perhaps, but no matter the degree of optimisation, the 16 byte of space is performed in two instructions. This leads me to believe is it most likely a pipelining issue for the following pushl instructions. As for subl'ing and addl'ing 8 bytes

Re: syscall assembly

2000-12-13 Thread Matt Dillon
: :gcc tries to align stack to 16 byte boundaries as a speed :optiminzation. Why it doesn't do this in one instruction is beyond :me. : :Kocking 16 bytes off the stack pointer won't put it any closer to a :16 byte boundary. This is precisely my problem with gcc's 'optimization'. It's

Re: syscall assembly

2000-12-13 Thread Drew Eckhardt
drew writes: My best guess (if it isn't a bug) would be that it's there to keep the stack on a 32 byte (IIRC, this sounds like cache line size for the newer Intel chips) This discussion piqued my curiosity, so I popped up the Pentium III optomization manual. To quote it: On Pentium II

Re: syscall assembly

2000-12-13 Thread Bakul Shah
#include fcntl.h int foo() { open("file", O_RDONLY); return 0; } int main() { int x; x = foo(); return 0; } results in: foo: pushl %ebp movl %esp,%ebp subl $8,%esp addl $-8,%esp pushl $0 pushl