函数调用过程中堆栈运行情况
来源:互联网 发布:中科大gpa算法 编辑:程序博客网 时间:2024/05/01 11:33
IA32 programs make use of the program stack to support procedure calls. The stack is used to pass procedure arguments, to store return information, to save registers for later restoration, and for local storage. The portion of the stack allocated for a single procedure call is called a stack frame. Figure 3.16 diagrams the general structure of a stack frame. The topmost stack frame is delimited by two pointers, with register %ebp serving as the frame pointer, and register %esp serving as the stack pointer. The stack pointer can move while the procedure is executing, and hence most information is accessed relative to the frame pointer.
Suppose procedure P (the caller) calls procedure Q (the callee). The arguments to Q are contained within the stack frame for P. In addition, when P calls Q, the return address within P where the program should resume execution when it returns from Q is pushed on the stack, forming the end of P’s stack frame. The stack frame for Q starts with the saved value of the frame pointer (i.e., %ebp). followed by copies of any other saved register values.
Procedure Q also uses the stack for any local variables that cannot be stored in registers. This can occur for the following reasons:
1. There are not enough registers to hold all of the local data.
2. Some of the local variables are arrays or structures and hence must be accessed by array or structure references.
3. The address operator ‘&’ is applied to one of the local variables, and hence we must be able to generate an address for it.
Finally, Q will use the stack frame for storing arguments to any procedures it calls.
As described earlier, the stack grows toward lower addresses and the stack pointer %esp points to the top element of the stack. Data can be stored on and retrieved from the stack using the pushl and popl instructions. Space for data with no specified initial value can be allocated on the stack by simply decrementing the stack pointer by an appropriate amount. Similarly, space can be deallocated by incrementing the stack pointer.
- 函数调用过程中堆栈运行情况
- C++ 中函数调用的堆栈过程
- 函数调用堆栈变化情况
- 函数调用堆栈变化情况
- 函数调用中堆栈
- 堆栈、栈帧、函数调用过程
- 堆栈和函数调用过程
- 函数的调用堆栈过程
- 函数调用时堆栈的变化情况
- 和菜鸟一起学c之函数中堆栈及运行内存情况
- 和菜鸟一起学c之函数中堆栈及运行内存情况
- 和菜鸟一起学c之函数中堆栈及运行内存情况
- 函数调用过程内存堆栈变化分析
- 函数调用具体过程-堆栈【1】
- <深入浅出>函数调用过程堆栈变化分析
- 计算机系统函数(过程)调用堆栈分析
- C语言函数堆栈调用过程
- C语言函数调用模型[调用过程中在堆栈中的出栈、进栈顺序]
- 用mtrace检查内存泄漏
- U-BOOT分析(smdk2410.c)
- java加密解密
- 一段复合查询的sql语句备份 排序 group
- android面试题目及其答案
- 函数调用过程中堆栈运行情况
- UVALive4922_Queen Collision
- Android入门第十一篇之TabHost,TabWidget
- Maximo 5.1安装手册 步骤
- struts2的action方法匹配以及通配符的使用
- Twebbrowser控件如果写多线程
- JAVA内部类的作用
- Stram读取网络文件
- 使用SQL如何把用逗号等字符隔开的字符串转换成列表