Assembler generated by gcc

Toon Knapen toon.knapen@fft.be
Wed Apr 7 12:16:00 GMT 2004


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




More information about the Gcc-help mailing list