This is the mail archive of the gcc-bugs@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]

x86 assembly output



Does anyone know why the x86 assembly language output from g++ does not
conform to the standard Intel convention?

For example, compile the null C++ program, and the output is:

        .file   "void.cc"
gcc2_compiled.:
___gnu_compiled_cplusplus:
.text
        .align 2
.globl _main
        .type    _main,@function
_main:
        pushl %ebp
        movl %esp,%ebp
        call ___main
        xorl %eax,%eax
        jmp L1
        .align 2,0x90
L1:
        leave
        ret
Lfe1:
        .size    _main,Lfe1-_main



The movl line above shows:
movl %esp,%ebp

when it should be:
movl %ebp,%esp

According to Intel Architecture Software Developer's Manual page 3-286,
the source register should be on the right, and the destination register
should be on the left.  However, when the code is compiled, the correct
form (the latter one) is used.  Borland C++ and MS Visual C++ both follow
the Intel convention. 

Is this a bug or does g++ have its own convention?



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