从代码到内存:通用入门指南
1. 代码示例与栈帧设置
先来看一段汇编代码:
PUSH EBP ; put EBP (register) on the stack MOV EBP, ESP ; set EBP to value of ESP (register, top of stack) PUSH -1 ; put -1 (immediate) on the stack ADD ESP, 4 ; negate the 'PUSH -1' to put ESP back where it was (a PUSH ; subtracts 4 from ESP, since it grows the stack) MOV ESP, EBP ; set ESP to the value of EBP (they will be the same anyway, ; since we have kept ESP in the same place) POP EBP ; set EBP to the value on top of the stack (it will be what ; EBP started with, put on the stack by PUSH EBP) XOR EAX, EAX ; exclusive-or EAX (register) with itself (same effect as ; 'MOV EAX, 0' but much