stack questions
Dave Klint
davek@ca.mgisoft.com
Tue Aug 1 21:04:00 GMT 2000
Just a few basic questions about stack management and what
is gcc dependant and what is platform dependant:
Some facts that I hope I'm not wrong on:
1) each argument to a function is pushed on to the stack so that
the last argument in the list is highest on the stack.
2) the return value of a function is contained in %eax (on x86).
3) the return address of a function is (should be) contained at the
top of the stack when "ret" is called
4) after a function call, gcc adds 4*number_of_parameters to the
stack pointer. A function with 3 arguments would have 12 added
to the stack pointer after the function call.
Because of this, I assume that external functions (implemented in
asm, for example) would get to its parameters by using offsets
from the stack pointer, and should never have unbalanced push/pop's.
Is there any other strangeness in the parameter passing in gcc
that I should be aware of?
Thanks in advance,
-dave
More information about the Gcc-help
mailing list