views:

181

answers:

2

is it possible to get the effective starting address of a stack after completing stack operations like push and pop in assembly programming?

A: 

simplest case is just to save initial stack pointer to some variable to access it when needed. If it not the case, use platform specific API, for example VirtualQuery on Windows, using current SP value as first parameter. base address will be in BaseAddress field of MEMORY_BASIC_INFORMATION structure. On posix task can be done using pthread functions

drlazy
Please edit and clean up Windows versus Posix. I fixed the first one ...
bmargulies
could you please explain how can it be done on MASM...
ruchir patwa
+1  A: 

The convention is to save (E)SP to (E)BP in the beginning of your function, and use (E)BP for local variable addressing.

Jens Björnhager