J
John
I would like to understand the following C++/C program in assembly
int main(void){
return 0;
}
================g++ -O -S compile.cpp
.file "x.c"
.def ___main; .scl 2; .type 32; .endef
.file "x.c"
.def ___main; .scl 2; .type 32; .endef
.text
.align 2
.p2align 4,,15
..globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl $16, %eax
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
call __alloca
call ___main
leave
xorl %eax, %eax
ret
What is actually going on? Why subtract 8 from esp (is that the stack
pointer?)
why this magical -16? what happens when alloca and main are called?
What
is leave and xorl? Is there a explanation of something like this or a
tutorial on
the web that can help me understand this?
Thanks a lot,
--j
int main(void){
return 0;
}
================g++ -O -S compile.cpp
.file "x.c"
.def ___main; .scl 2; .type 32; .endef
.file "x.c"
.def ___main; .scl 2; .type 32; .endef
.text
.align 2
.p2align 4,,15
..globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl $16, %eax
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
call __alloca
call ___main
leave
xorl %eax, %eax
ret
What is actually going on? Why subtract 8 from esp (is that the stack
pointer?)
why this magical -16? what happens when alloca and main are called?
What
is leave and xorl? Is there a explanation of something like this or a
tutorial on
the web that can help me understand this?
Thanks a lot,
--j