How the program stack avoids
overwriting parameters and local variables
Properties of the
stack:
- A stack will
grow when
new data
are pushed on the
stack
- The new data pushed
on the stack will
not overwrite
the
old data
stored inside the stack
|
How the program stack avoids overwriting parameters and local variables
Example:
suppose that
main( )
calls A( ) and then
A( ) calls
B( ):
How the program stack avoids overwriting parameters and local variables
Example:
suppose that
main( )
calls A( ) and then
A( ) calls
B( ):
How the program stack avoids overwriting parameters and local variables
Conclusion:
- When caller function A( )
calls
another function (B( )),
the other function (B( ))
will not overwrite the
memory space
reserved for
A( )'s parameters and local
variables !!!
|
DEMO:
/home/cs255001/demo/asm/8-sub/prelude.s
❮
❯