Question about assembly produced by gcc

Yannis Haralambous yannis.haralambous@enst-bretagne.fr
Mon Dec 19 22:11:00 GMT 2005


Hi, I have a small question about assembler code generated by gcc:
when I compile the trivial program main () {} with gcc -O0 I get the  
following lines

         pushl   %ebp
         movl    %esp, %ebp
         subl    $8, %esp
         andl    $-16, %esp

which are very clear. But also the following lines:

         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?
Could you tell me what is going on? Or point me to documentation or  
to a knowledgeable person?

Thanks in advance!!

Yannis

--
+--------------------------------------------------------------------+
| Yannis Haralambous, Ph.D.      yannis.haralambous@enst-bretagne.fr |
| Directeur d'Études                   http://omega.enstb.org/yannis |
|                                          Tel. +33 (0)2.29.00.14.27 |
|                                          Fax  +33 (0)2.29.00.12.82 |
| Département Informatique                                           |
| École Nationale Supérieure des Télécommunications de Bretagne      |
| Technopôle de Brest Iroise, CS 83818, 29238 Brest CEDEX 3, France  |
+--------------------------------------------------------------------+
                          ...pour distinguer l'extérieur d'un aquarium,
                                         mieux vaut n'être pas poisson

                         ...the ball I threw while playing in the park
                                        has not yet reached the ground

            Es gab eine Zeit, wo ich nur ungern über Schubert sprechen,
         nur Nächtens den Bäumen und Sternen von ihm vorerzählen mögen.




More information about the Gcc-help mailing list