Page 1 of 1

C parameters

Posted: Sun Jul 13, 2003 11:00 pm
by pepito
I know that a C compiler use the stack to pass parameters to functions.

I complie a little program with GCC using the -S option, to view the code it create and I realize that always put this two lines after a function call:

pushl $73
call _putch
addl $16, %esp  <--- This,
subl $12, %esp  <--- and this.

Are these two lines used to restore the stack pointer?
When a C compiler 'pop' the values passed as parameter?

Thank you

pepito

RE:C parameters

Posted: Sun Jul 13, 2003 11:00 pm
by Chase
"pop"s aren't done when dealing with passing parameters to methods. Look at the details at http://www.osdev.org/developers/guide01/index.jsp It describes what gcc does at the asm level.

If I remeber correctly gcc "reserves" extra stack space sometimes so you don't really pay attention if gcc modifies esp by strange values.

-Chase