C parameters

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pepito

C parameters

Post 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
Chase

RE:C parameters

Post 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
Post Reply