当前位置:网站首页>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]
边栏推荐
- SQL Injection (GET/Search)
- Universal dividend source code, supports the dividend of any B on the BSC
- Sequence table (implemented in C language)
- Golang — template
- Comprehensively develop the main channel of digital economy and digital group, and actively promote the utonmos digital Tibet market
- Unity render streaming communicates with unity through JS
- Flutter dynamic | fair 2.5.0 new version features
- JS convert pseudo array to array
- MySQL installation, uninstallation, initial password setting and general commands of Linux
- [bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update
猜你喜欢
Richview trvstyle liststyle list style (bullet number)
双向链表(我们只需要关注插入和删除函数)
使用tensorflow进行完整的DNN深度神经网络CNN训练完成图片识别案例
[bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update
RichView TRVStyle ListStyle 列表样式(项目符号编号)
[technology development-24]: characteristics of existing IOT communication technology
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
Qt学习20 Qt 中的标准对话框(中)
Unity EmbeddedBrowser浏览器插件事件通讯
Use and design of Muduo buffer class
随机推荐
解决MySql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES)
GoLand 2021.1.1: configure the multi line display of the tab of the open file
The shadow of the object at the edge of the untiy world flickers, and the shadow of the object near the far point is normal
Using registered classes to realize specific type matching function template
Replace the GPU card number when pytorch loads the historical model, map_ Location settings
使用tensorflow进行完整的DNN深度神经网络CNN训练完成图片识别案例
Flutter dynamic | fair 2.5.0 new version features
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
IBEM 数学公式检测数据集
Dynamic programming 01 knapsack and complete knapsack
Error handling when adding files to SVN:.... \conf\svnserve conf:12: Option expected
8 Queen question
MySQL 数据增删改查综合案例
[understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered
静态链表(数组的下标代替指针)
KEIL5出现中文字体乱码的解决方法
Summary of common error reporting problems and positioning methods of thrift
Kivy tutorial how to automatically load kV files
Qt学习18 登录对话框实例分析
pytorch 载入历史模型时更换gpu卡号,map_location设置