问题
I know that call and ret will modify the value of esp and that push and pop have a number of variants, but are there other instructions that will affect the stack pointer ?
回答1:
The following instructions modify the stack pointer1:
callenterint n/into/int 3iret/iretdleavepoppushretsysentersysexitpusha/pushadpopa/popadpushf/pushfd/pushfqpopf/popfd/popfqvmlaunch/vmresumeeexit
I leave to you the burden of telling primary and side effects apart.
Keep in mind that any instruction capable of generating an exception can potentially modify the stack pointer.
I've not considered such instructions in order to avoid trivializing your question.
Those are all the instructions I can find by searching the Intel manuals at the time of creation of this answer.
While I did my best scrutinizing the manuals I wouldn't swear to that list.
1 Either SP, ESP or RSP.
回答2:
The push(a/ad/f) and pop(a/ad/f) instruction group are modifying the stack pointer (e)sp. Interrupt calls int also modify it. The instruction call will push the return address to the stack and ret removes it. In the form of ret NUMBER additionally the number of bytes are removed from the stack to clean it.
Of cause you can use (e)sp in other instructions, like mov or arithmetic instructions like add or sub. It will be represented in the R/M or REG fields of the opcode.
来源:https://stackoverflow.com/questions/44144038/what-are-the-x86-instructions-that-affect-esp-as-a-side-effect