堆栈帧中的局部变量

时间:2016-02-21 07:05:52

标签: assembly stack

假设你有一个堆栈框架......

push %ebp
movl %esp, %ebp
subl $20, %esp

High (+)
+-------------+
|             |
|  old %ebp   |
|             |
|             |
+-------------+ %ebp
|             |
|             |
|             |
|             |
|             |
|             |
|             |
|             |
+-------------+ $esp
Low (-)

假设你接受一个双字(4个字节),并将它移动到(%esp)......

movl $0x44415441, (%esp) #0x44415441 being "DATA" in hex for ASCII...

堆栈看起来像这样吗?

High (+)
+-------------+
|             |
|  old %ebp   |
|             |
|             |
+-------------+ %ebp
|             |
|             |
|             |
|             |
+-------------+
|      D      |
|      A      |
|      T      |
|      A      |
+-------------+ %esp
Low (-)

还是这个?

High (+)
+-------------+
|             |
|  old %ebp   |
|             |
|             |
+-------------+ %ebp
|             |
|             |
|             |
|             |
|             |
|             |
|             |
|             |
|             |
+-------------+ %esp
|      D      |
|      A      |
|      T      |
|      A      |
+-------------+
Low (-)

此外,这四个字节是否会在内存中这样排列......

High (+)
+-------------+
|      D      |
|      A      |
|      T      |
|      A      |
+-------------+
Low (-)

或者像这样...

High (+)
+-------------+
|      A      |
|      T      |
|      A      |
|      D      |
+-------------+
Low (-)

0 个答案:

没有答案