Page 1 of 1

Dumping stack?

Posted: Fri Jan 23, 2004 12:23 pm
by St8ic
When I dump my stack to the screen (with my dump(); routine), it shows

00 00 00 00 00 00 00 00 00 (then ASCII symbols)

I'm hoping my stack isn't empty! The input to my dump routine has the location of data to dump (in this case it's 0x9000, my stack), and the length in bytes to display. The stack IS at 0x9000, I checked, but it still displays 00's. Do I have to lead my stack or something, or is it actualy empty?

Thanks bunches.

Re:Dumping stack?

Posted: Fri Jan 23, 2004 12:33 pm
by nullify
Is 0x9000 the address of your stack base, or your stack pointer (ESP)? Remember, the stack grows from the stack base downward, so if that address points to the base of your stack, your dump() function has to dump out bytes progressively lower each iteration.

Re:Dumping stack?

Posted: Fri Jan 23, 2004 5:54 pm
by St8ic
Actualy I didn't know that! I'll use a ESP. Thanks!

Re:Dumping stack?

Posted: Sat Jan 24, 2004 6:38 am
by mystran
Notice, that this also affects the memory allocation process for stacks. When you allocate a region of memory for stack, you have to set ESP to the END of that region, before you start using your stack, or you are going to write just below your allocated memory..