I am taking a class right now and as part of the research project there is a question on how the ESP/RSP pointer is used in relation to popping the return address on a stack frame into the register.
Now looking up the leave instruction I found the following in the manual https://c9x.me/x86/html/file_module_x86_id_154.html
"Releases the stack frame set up by an earlier ENTER instruction. The LEAVE instruction copies the frame pointer (in the EBP register) into the stack pointer register (ESP), which releases the stack space allocated to the stack frame. The old frame pointer (the frame pointer for the calling procedure that was saved by the ENTER instruction) is then popped from the stack into the EBP register, restoring the calling procedure's stack frame.
A RET instruction is commonly executed following a LEAVE instruction to return program control to the calling procedure."
So if what its saying here, and I am just looking for verification because several Youtube videos have seemed to mangle this process;
My thinking is: EBP is copied to ESP than what is being pointed at by ESP is placed into the EBP pointer as now we are back to our previous frame.