I have read many books and instructions on this, but one thing that is never specified is what happens to a register after you push it on the stack. For example if you write in
The register keeps its value after push instruction.
push effects two places: the stack memory that get new value, and the value of esp which now points to the new top.
You can deduce that from the description of push operation:
if(StackAddressSize == 32) {
if(OperandSize == 32) {
ESP = ESP - 4;
SS:ESP = Source //push doubleword
}
else { //OperandSize == 16
ESP = ESP - 2;
SS:ESP = Source; //push word
}
}
else { //StackAddressSize == 16
if(OperandSize == 16) {
SP = SP - 2;
SS:ESP = Source //push word
}
else { //OperandSize == 32
SP = SP - 4;
SS:ESP = Source; //push doubleword
}
}
source: https://c9x.me/x86/html/file_module_x86_id_269.html
https://c9x.me/x86/ is a great pocket reference for x86 instructions, use it at will!