X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: eplmst AT lu DOT erisoft DOT se (Martin Stromberg) Newsgroups: comp.os.msdos.djgpp Subject: Re: Assembly Question: Date: 11 Feb 2002 13:10:29 GMT Organization: Ericsson Erisoft AB, Sweden Lines: 39 Message-ID: References: <000a01c1b296$f2b0dc00$34e2a0c8 AT rjo DOT virtua DOT com DOT br> NNTP-Posting-Host: lws256.lu.erisoft.se X-Newsreader: TIN [version 1.2 PL2] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Babu Kalakrishnan (kala AT sankya DOT com) wrote: : On Sun, 10 Feb 2002 21:56:07 -0300, Pedro Izecksohn wrote: : > When "gcc asmtest.c -S" the code below: : > : >void test1 () { : >} : > : >void main () { : >test1(); : >} : > : > gcc makes the following .S code: (Without the lines numbers.) : > : >12 _main: : >13 pushl %ebp : >14 movl %esp, %ebp : >15 subl $8, %esp : >16 andl $-16, %esp : >17 call _test1 : >18 movl %ebp, %esp : >19 popl %ebp : >20 ret : >21 .ident "GCC: (GNU) 3.0.3" : > : > What is the purpose of the lines 15 and 16 ? : These are obviously meant for ensuring 16 byte stack alignment. I'm not : sure why both statements are present though. May be the first one is : part of the entry code (to correct for the pushed return address and : pushed ebp occupying 8 bytes) - and the second is a part of the function : call code (ensuring 16 byte alignment before calling the function). It there because the original poster didn't turn on optimisations. Try with "-O2", see the difference and take note. Right, MartinS