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 performa

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

Re: syscall assembly

2000-12-13 Thread Bakul Shah
> > #include > > > > 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 > >

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 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
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

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 a

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

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 purpos

Re: syscall assembly

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

Re: syscall assembly

2000-12-13 Thread Alfred Perlstein
David, can you look at this? #include 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 call op

Re: syscall assembly

2000-12-13 Thread Drew Eckhardt
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] write s: >> subl $8,%esp >> addl $-8,%esp >> What is the purpose of the subl and addl >> instructions? On Linux, they are simply >> unexistent.. > >FreeBSD passes syscall args on the stack, Linux uses registers. The 'C' compiler d

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.

Re: syscall assembly

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