Page 1 of 1
Mysterious item on stack
Posted: Sat Jun 14, 2008 3:41 pm
by veganisafreak
Hello, I have found Mysterious Item on Stack.
I could end my post there but that's not very informative.
Right, I was looking at the stack trace window, trying to find out where PB stores a procedure's local variables... the manual doesn't have much to say about it... and I found that in between the procedure's arguments, and the local variables, there was another 32 bit value that I didn't know what it was...
Does anyone know?
Can I rely on it being there all the time? Did I dream this?
PS I thought it might be a saved EBP but since PB uses ESP to reference stack variables, it wouldn't need to save EBP would it?
Posted: Sat Jun 14, 2008 8:13 pm
by srod
... the manual doesn't have much to say about it...
Why should it, it's really an internal matter? Anyhow, the first thing PB does in a procedure is push the EBX register, to be popped at procedure's end.
Re: Mysterious item on stack
Posted: Sun Jun 15, 2008 12:04 pm
by tinman
veganisafreak wrote:Right, I was looking at the stack trace window, trying to find out where PB stores a procedure's local variables... the manual doesn't have much to say about it... and I found that in between the procedure's arguments, and the local variables, there was another 32 bit value that I didn't know what it was...
Return address?
Posted: Sun Jun 15, 2008 12:41 pm
by freak
Just compile your code with the /commented switch from a console and you can look
at the assembly code to see what is done exacly when calling the procedure.
Posted: Mon Jun 16, 2008 11:06 am
by Trond
srod wrote:... the manual doesn't have much to say about it...
Why should it, it's really an internal matter? Anyhow, the first thing PB does in a procedure is push the EBX register, to be popped at procedure's end.
That's only if it's used.
The number in between is the return address.
Posted: Mon Jun 16, 2008 4:17 pm
by veganisafreak
Thanks everyone.
Especially freak I was wondering how to get hold of the asm output!
Posted: Wed Jun 18, 2008 4:50 pm
by veganisafreak
This sunk in over the last couple days. I can't believe I referred to the return address as a mysterious item. What an idiot. I assumed the return address would be higher up the stack somewhere...
Posted: Wed Jun 18, 2008 5:10 pm
by Kaeru Gaman
I guess PB pushes the ReturnAdr first and then the Parameters,
because the Params need to be popped in the beginning of the procedure,
but the ReturnAdr only at the end....
Posted: Wed Jun 18, 2008 8:05 pm
by Trond
PB never pushes the return address "conciously", the processor pushes it automatically when it runs the call instruction.