> which are very clear. But also the following lines:
>
>          andl    $-16, %esp
>          movl    $0, %eax
>          addl    $15, %eax
>          addl    $15, %eax
>          shrl    $4, %eax
>          sall    $4, %eax
>       subl    %eax, %esp
>
> of which I understand the semantics individually, but I don't see
> what are needed for. Why put 0 into %eax and then add 15 and again
> add 15?

The best thing I can tell you is to ask on the gcc newsgroup or
comp.compilers.

However, remember that when you compile with -O0 you are getting no
optimizations whatsoever.  What is likely going on is that it is
calculating some sort of stack offset on piece at a time.  When you
compile with -O3 you get something much more sensible:

        pushl   %eax
        pushl   %eax
        andl    $-16, %esp
        subl    $16, %esp

While still not really needed for an empty function, it makes sense
nonetheless.   It aligns the stack on a 16-byte boundary.  Which, in fact,
the computation for %eax above results in 16.

If you compile with  -O0 -mpreferred-stack-boundary=2 you will get the
results you expect.

Jon


_______________________________________________
Pgubook-readers mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/pgubook-readers

Reply via email to