该问题与 Assembly x86-32 RET n 指令有关

The question is related to Assembly x86-32 RET n instruction

我知道Ret n 的意思,但是想不通它维护程序运行时栈的作用?我有点困惑。 ret 和堆栈有关系吗?

ret n 就像 ret + add esp, n。您将它用于 caller-pops 调用约定。

普通 ret 就像 pop eip。 (pop eip 不是有效指令,但它很好地表达了 ret 的作用)。是的,它使用堆栈;阅读文档。 http://felixcloutier.com/x86/RET.html(特别是 "near return" 部分。)

"far ret" 更复杂,但不用于具有平面内存模型的 32 位或 64 位代码。即在正常代码中根本不使用。