* gcc assembler output oddness
@ 2004-05-19 21:05 kazuo
2004-05-19 21:56 ` Eljay Love-Jensen
0 siblings, 1 reply; 2+ messages in thread
From: kazuo @ 2004-05-19 21:05 UTC (permalink / raw)
To: gcc-help
Please forgive me if I'm emailing the wrong list. I was referred by the gcc
documentation.
Hello, I'm a student having a bit of trouble compiling with gcc. I attempted to
compile a few programs with the -S option, and got pretty strange results... is
this a feature, or something I somehow should understand?
I copied below the files outputed and what I expected. Some instructions are of
extreme strangeness, such as
mov $0, %eax
subl %eax, %esp
What is the point of doing this? For one thing, stdcall doesn't require %eax to
be zeroed(or does it?). Whatmore, it's totally weird and useless to subtract
zero from any value, especially considering no conditional jump follows...
So what am I missing?
thank you,
Kazuo
kazuo@linux.ime.usp.br
#########################################
# file 1: the code the way i expected it
#########################################
.file "blah.c"
.section .rodata
.LC0:
.string "hello world\n"
.text
.globl somefunc
.type somefunc,@function
somefunc:
pushl %ebp
movl %esp, %ebp
pushl $.LC0
call printf
leave
ret
.Lfe1:
.size somefunc,.Lfe1-somefunc
.globl main
.type main,@function
main:
pushl %ebp
movl %esp, %ebp
call somefunc
movl $0, %eax
leave
ret
.Lfe2:
.size main,.Lfe2-main
.ident "kaz 0.0001"
#################################
# file 2: the code by gcc 3.2.3
#################################
.file "blah.c"
.section .rodata
.LC0:
.string "hello world\n"
.text
.globl somefunc
.type somefunc,@function
somefunc:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
subl $12, %esp
pushl $.LC0
call printf
addl $16, %esp
leave
ret
.Lfe1:
.size somefunc,.Lfe1-somefunc
.globl main
.type main,@function
main:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
movl $0, %eax
subl %eax, %esp
call somefunc
movl $0, %eax
leave
ret
.Lfe2:
.size main,.Lfe2-main
.ident "GCC: (GNU) 3.2.3"
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-05-19 21:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-19 21:05 gcc assembler output oddness kazuo
2004-05-19 21:56 ` Eljay Love-Jensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).