At the beginning, %ebp is usually set to %esp. If I set up the stack pointer to some particular location, does the base pointer also change?
And do I need to change it to a new location, say $(newstacklocation - 4)?
At the beginning, %ebp is usually set to %esp. If I set up the stack pointer to some particular location, does the base pointer also change?
And do I need to change it to a new location, say $(newstacklocation - 4)?
The base pointer and the stack pointer are separate registers. The base pointer only changes when you set it to a new value. Setting the stack pointer does not implicitly change any other general purpose registers.
Incidentally, this is the whole reason for keeping a base pointer around: if you push or pop the stack, the stack pointer changes and so do all esp-relative offsets. The base pointer does not change however, so ebp-relative offsets for variables on the stack remain constant. This makes writing functions in assembly much easier as you can amend the stack frame without having to fix all the stack offsets.
Instructions only do what they say in Intel/AMD's manual, in the Operation section.
sub $12, %esp is no different from sub $12, %eax. SUB modifies the destination register (and EFLAGS with the condition codes), that's all.
And EIP advances to the next instruction, the same as always. Not usually mentioned for non-branch instructions, but running any instruction does advance EIP.
There is no other magic effect on the architectural state. This is assembly language. Everything is just bytes in memory or registers. Anything that you want to happen to those bytes, you have to make it happen yourself by making the CPU run instructions.
If you use an instruction like leave, then yes it will change both ESP and EBP, equivalent to
mov %ebp, %esp
pop %ebp
Because that's what it says in the manual for leave.