小编chi*_*ech的帖子

推送局部变量

ALO

在我从http://en.wikibooks.org/wiki/X86_Disassembly/Functions_and_Stack_Frames上读到函数和堆栈后,我对局部变量有疑问.

文章快照:


push ebp     ; save the value of ebp
mov ebp, esp ; ebp now points to the top of the stack
sub esp, 12  ; space allocated on the stack for the local variables
Run Code Online (Sandbox Code Playgroud)

这意味着可以通过引用ebp来访问局部变量.考虑以下C代码片段和相应的汇编代码:

a = 10;
b = 5;
c = 2;

mov [ebp -  4], 10  ; location of variable a
mov [ebp -  8], 5   ; location of b
mov [ebp - 12], 2   ; location of c
Run Code Online (Sandbox Code Playgroud)

请记住,推送基本上是这样的:

sub esp, …
Run Code Online (Sandbox Code Playgroud)

assembly

6
推荐指数
1
解决办法
8717
查看次数

标签 统计

assembly ×1