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]
Other format: [Raw text]

RE: Calling functions on x86


----Original Message----
>From: patriciak784-gccmainling
>Sent: 20 September 2005 12:15

> On x86 and GCC 3.4.2, the resulting asm code when
> leaving a stackframe is (in intel_syntax)
> mov esp,ebp
> pop ebp
> .(results in 0x89EC5D or 0x8BE55D)
> The AMD optimisation guide for AMD64 tells you not to
> use mov esp, ebp - pop ebp but to use "leave"(just
> 0xC9)!


  I don't have a 64bit version, but did you try using the appropriate
-march= option?


dk@mace /test/leave> cat foo.c

int foo (void)
{
  return 9;
}

dk@mace /test/leave> gcc -O0 -S foo.c -o foo.s
dk@mace /test/leave> cat foo.s
        .file   "foo.c"
        .text
.globl _foo
        .def    _foo;   .scl    2;      .type   32;     .endef
_foo:
        pushl   %ebp
        movl    %esp, %ebp
        movl    $9, %eax
        popl    %ebp
        ret
dk@mace /test/leave> gcc -O0 -S -march=athlon-xp foo.c -o foo.s
dk@mace /test/leave> cat foo.s
        .file   "foo.c"
        .text
.globl _foo
        .def    _foo;   .scl    2;      .type   32;     .endef
_foo:
        pushl   %ebp
        movl    %esp, %ebp
        movl    $9, %eax
        leave
        ret
dk@mace /test/leave>


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


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