当前位置:网站首页>Grasp the detailed procedure of function call stack from instruction reading
Grasp the detailed procedure of function call stack from instruction reading
2022-06-27 20:02:00 【Invincible Dragon Warrior】
List of articles
int sum(int a, int b)
{
int temp = 0;
temp = a + b;
return temp;
}
int main()
{
int a = 10; //
int b = 20;
int ret = sum(a, b);
cout << ret << endl;
}
1 mian Function call sum,sum After execution , How do you know to go back to that function ?
2 sum Function execution finished , go back to main in the future , How do you know which line of instruction to continue execution from ?

- ESP: It stores the address of the top of the current function stack frame
- EBP: What's stored is main The address at the bottom of the function stack
int a = 10 => mov dword ptr[a], 0Ah perhaps mov dword ptr[ebp - 4], 0Ah
int b = 20; => mov dword ptr[ebp - 8], 14h

sum(a, b)
= >
mov eax, dword ptr[ebp-8]
push eax // b
mov eax, dword ptr[ebp-4]
push eax //a

int ret = sum(a, b)
call sum
add esp, 8 // The address is 0x08124458
mov dword ptr[ebh - 0Ch], eax

int sum(int a, int b)
{ // push ebp
mov ebp, esp
sub esp, 4Ch
int temp = 0; mov dword ptr[ebp - 4] 0
temp = a + b; mov eax, dword ptr[ebp + 0Ch] a + b mov dword ptr[ebp - 4], eax
return temp; mov eax, dword ptr[ebp - 4]
}// mov esp, ebp
pop ebp

ret // The stack, Put the contents of the stack into CPU Of PC In the register

边栏推荐
- redis数据结构
- [login interface]
- On thread safety
- Observable, reliable: the first shot of cloudops series Salon of cloud automation operation and maintenance
- [help] troubleshooting of JVM's high CPU resource consumption
- 1024 Palindromic Number
- muduo
- Redis集群
- (LC)46. 全排列
- [debug] platform engineering interface debugging
猜你喜欢

database engine

UE4:Build Configuration和Config的解释

The Fifth Discipline: the art and practice of learning organization

Data intelligence enters the "deep water area", and data governance is the key

redis数据结构

可观测,才可靠:云上自动化运维CloudOps系列沙龙 第一弹

Database lock problem

UE4: explanation of build configuration and config

Bit. Store: long bear market, stable stacking products may become the main theme

【登录界面】
随机推荐
1023 Have Fun with Numbers
拥抱云原生:江苏移动订单中心实践
shell脚本常用命令(三)
Bit.Store:熊市漫漫,稳定Staking产品或成主旋律
聊聊毕业季
海底电缆探测技术总结
Logcli-loki 命令行工具
Question brushing record: easy array (continuously updated)
What is ssr/ssg/isr? How do I host them on AWS?
ABAP-SM30删除前检查
键入网址到网页显示,期间发生了什么?
数据库引擎
UE4随笔:FString、FName 与 FText
Crontab's learning essays
数组练习 后续补充
指针和结构体
数据库日志
1027 Colors in Mars
数据库索引
Redis cluster Series III