What are the x86 instructions that affect ESP as a side effect?

懵懂的女人 提交于 2020-08-20 02:01:50

问题


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:

  • call
  • enter
  • int n/into/int 3
  • iret/iretd
  • leave
  • pop
  • push
  • ret
  • sysenter
  • sysexit
  • pusha/pushad
  • popa/popad
  • pushf/pushfd/pushfq
  • popf/popfd/popfq
  • vmlaunch/vmresume
  • eexit

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!