This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

3.0 Changes in ASM


Hi all,

I was wondering about the changes in the assembly language for the
following C code:

#include <stdio.h>

int main(void)
{
    printf("hello world\n");
    return 0;
}

GCC 2.95.2 outputs the following asm code:

main:
        pushl %ebp
        movl %esp,%ebp
        subl $8,%esp
        addl $-12,%esp
        pushl $.LC0
        call printf
        addl $16,%esp
        xorl %eax,%eax
        jmp .L2
        .p2align 4,,7
.L2:
        movl %ebp,%esp
        popl %ebp
        ret

while 3.0 outputs:

main:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $8, %esp
        subl    $12, %esp
        pushl   $.LC0
        call    printf
        addl    $16, %esp
        movl    $0, %eax
        movl    %ebp, %esp
        popl    %ebp
        ret

The question is, why the "movl $0, %eax" when an "xor" is typically
faster (or so I'm lead to believe)?

-- 
|| Bill Wendling			wendling@ncsa.uiuc.edu
|| Coding Simian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]