What is the register EBP used for, besides creating stack frames? We can't store values in it because the program crashes. Have EBP any utility?

Posted on 2004-06-21 19:10:58 by Marginais
EBP is normally used for stack frames, but if you save it's value you can use it as any other 32bit register - of course this would also mean that procedure arguments and local variables are inaccessible from masm, and that you would have to use direct ESP references to access these.
Posted on 2004-06-21 19:34:26 by f0dder
As f0dder says it is used in conjuction with the stack. It really just makes stack frames a little easier by providing a static base pointer to calculate addresses from for example since the value of EBP on entry into a procedure is changed to the base of the procedural stack...

PUSH ; Local DWORD 1
PUSH ; Local DWORD 2

You could calculate this using ESP however your assembler would have to keep track of every push and pop and every invoke in order to know the displacement from equilibrium. For example...

push VAR1
= VAR1
push VAR2
= VAR1
= VAR2

As you can see the displacement for VAR1 changed as a result of the PUSH. It is not an impossible task to handle this in an assembler but it is much easier with a fixed base pointer to work with.
Posted on 2004-06-21 19:46:52 by donkey
You can use ebp for anything so long you restore its value.. The same goes to esp, esi, edi and ebx.
Posted on 2004-06-22 02:34:46 by roticv