1
pop ebp
在代码的ret
(返回)指令之前在IA-32和x86-64机器中的含义是什么?所以我确实有新的和新的ebp
,并且新的ebp
通过函数的调用被推入堆栈。那么这个ebp
是pop
'ed? pop
指令如何更改ebp
的值?IA-32和x86-64 POP指令中的汇编
pop ebp
在代码的ret
(返回)指令之前在IA-32和x86-64机器中的含义是什么?所以我确实有新的和新的ebp
,并且新的ebp
通过函数的调用被推入堆栈。那么这个ebp
是pop
'ed? pop
指令如何更改ebp
的值?IA-32和x86-64 POP指令中的汇编
PUSH EAX
主要是指:
SUB ESP,4
MOV [ESP],EAX
而且
POP EAX
方式:
MOV EAX,[ESP]
ADD ESP,4
当你谈论老新的EBP
我想你是指的功能序言和结尾?
PUSH EBP ; Store caller's EBP on the stack
MOV EBP,ESP ; Set EBP to the current stack pointer
; Here we can do things like:
MOV EAX,[EBP+8]
PUSH EAX
MOV EBX,[EBP+12]
POP EAX
; ..to access the stack. Since we've got a fixed reference point for
; the stack in EBP we don't have to worry about the stack pointer
; changing.
; For example, we could do this instead to access the same stack
; elements as above:
MOV EAX,[ESP+8]
PUSH EAX
MOV EBX,[ESP+16]
POP EAX
; But notice that we had to change the second offset since the push
; instruction changed the stack pointer. It's obviously easier to deal
; with a base address that doesn't change every time we execute
; certain instructions.
MOV ESP,EBP ; Restore the stack pointer
POP EBP ; Restore the caller's EBP before returning
它几乎在任何代码中都是函数epilogue的一部分。它只是恢复堆栈帧指针,所以它又指向调用者的堆栈帧。在任何关于x86汇编编程的书中都涵盖了这一点 –
它如何改变ebp的价值? – user2519974