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

Assembler generated by gcc


The most simple C program

int main()
{
  return 13 ;
}


Results in following with 'gcc -S <file>' (gcc version 3.2.2)


	.file	"tt.c"
	.text
.globl main
	.type	main,@function
main:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$8, %esp
	andl	$-16, %esp
	movl	$0, %eax
	subl	%eax, %esp
	movl	$13, %eax
	leave
	ret
.Lfe1:
	.size	main,.Lfe1-main
	.ident	"GCC: (GNU) 3.2.2"


I would have expected 'main' to only contain

	movl $13, %eax
	leave
	ret

So now I wonder why all the statements before these 3 statements are in
'main'. I've searched in several assembler tutorials and manuals but did
not find an explanation.
Thanks for any tips (to some webpage or ...)

toon



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