当前位置:网站首页>Function calling convention
Function calling convention
2022-07-03 13:53:00 【yolo_ yyh】
Catalog
One 、 The role of function calling conventions
One 、 The role of function calling conventions
The function call is realized by the storage structure of stack , But there are several problems involved , Like the following function :
int add(int a, int b) {
return a + b;
}
int main {
add(1, 2);
return;
}(1) How to ensure the stack order of parameters ? First a after b, Or first? b after a?
(2) After the function call , Who is responsible for restoring the top pointer ?
Function calling convention is to solve these problems , And different function call conventions will produce different function name modifiers , Different language conventions are different , There are mainly :stdcall、cdecal、fastcalll.
Two 、stdcall
stdcall yes C++ Standard call mode of , The calling convention is :
1) Parameters are pushed right to left , Corresponding to the above example, first b after a;
2) The callee is responsible for restoring the stack top pointer
Because the variable parameters are similar printf(), The number of parameters is only known during execution , The callee does not know how many parameters are passed in , therefore stdcall The implementation of variable parameters is not supported .
Use stdcall The function name of the calling convention will be decorated with an underscore prefix plus @ And the number of bytes of the parameter , The above example is [email protected]
3、 ... and 、cdecal
yes C Language default calling convention ;
1) Parameters are pushed onto the stack from right to left ;
2) The caller is responsible for restoring the stack top pointer
And stdcall The only difference is who is responsible for restoring the top pointer and the name of the compiled function ,cdecal The function name compiled by the method has only one in front “_” Prefix .
Four 、fastcall
1) Parameters are pushed onto the stack from right to left ;
2) Call the function to recover the stack top pointer ;
3) Parameters are preferentially passed by registers .
fastcall The reason why it is fast is that parameters will be passed in priority using registers , The compiled function name format is :@[email protected]
边栏推荐
- Using registered classes to realize specific type matching function template
- [556. Next larger element III]
- Error handling when adding files to SVN:.... \conf\svnserve conf:12: Option expected
- 如何使用lxml判断网站公告是否更新
- Golang — template
- Use vscode to view hex or UTF-8 codes
- Richview trvstyle liststyle list style (bullet number)
- Go language web development series 27: Gin framework: using gin swagger to implement interface documents
- Father and basketball
- Flutter动态化 | Fair 2.5.0 新版本特性
猜你喜欢

SQL Injection (GET/Search)

Implementation of Muduo accept connection, disconnection and sending data

Mycms we media mall v3.4.1 release, user manual update

Brief analysis of tensorboard visual processing cases

Logback log sorting

Go language web development series 29: Gin framework uses gin contrib / sessions library to manage sessions (based on cookies)

Use and design of Muduo buffer class

GoLand 2021.1: rename the go project

MySQL 数据增删改查综合案例

GoLand 2021.2 configure go (go1.17.6)
随机推荐
Go language web development series 30: gin: grouping by version for routing
又一个行业被中国芯片打破空白,难怪美国模拟芯片龙头降价抛售了
Flutter动态化 | Fair 2.5.0 新版本特性
记录关于银行回调post请求405 问题
Golang — 命令行工具cobra
User and group command exercises
Comprehensively develop the main channel of digital economy and digital group, and actively promote the utonmos digital Tibet market
untiy世界边缘的物体阴影闪动,靠近远点的物体阴影正常
Screenshot of the operation steps of upload labs level 4-level 9
mysql中的字段问题
GoLand 2021.2 configure go (go1.17.6)
Go 1.16.4: manage third-party libraries with Mod
Can newly graduated European college students get an offer from a major Internet company in the United States?
【556. 下一个更大元素 III】
Unity render streaming communicates with unity through JS
太阳底下无新事,元宇宙能否更上层楼?
Qt学习22 布局管理器(一)
【电脑插入U盘或者内存卡显示无法格式化FAT32如何解决】
MapReduce implements matrix multiplication - implementation code
【被动收入如何挣个一百万】