当前位置:网站首页>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]
边栏推荐
- Replace the GPU card number when pytorch loads the historical model, map_ Location settings
- 【电脑插入U盘或者内存卡显示无法格式化FAT32如何解决】
- Swiftui development experience: the five most powerful principles that a programmer needs to master
- Richview trvstyle liststyle list style (bullet number)
- Ocean CMS vulnerability - search php
- NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
- Shell timing script, starting from 0, CSV format data is regularly imported into PostgreSQL database shell script example
- Comprehensive evaluation of double chain notes remnote: fast input, PDF reading, interval repetition / memory
- Golang - command line tool Cobra
- Unity EmbeddedBrowser浏览器插件事件通讯
猜你喜欢
【电脑插入U盘或者内存卡显示无法格式化FAT32如何解决】
Logback log sorting
如何使用lxml判断网站公告是否更新
Qt学习19 Qt 中的标准对话框(上)
Brief analysis of tensorboard visual processing cases
The solution of Chinese font garbled code in keil5
Mycms we media mall v3.4.1 release, user manual update
[technology development-24]: characteristics of existing IOT communication technology
GoLand 2021.1.1: configure the multi line display of the tab of the open file
[机缘参悟-37]:人感官系统的结构决定了人类是以自我为中心
随机推荐
mysql中的字段问题
Unity embeddedbrowser browser plug-in event communication
AI scores 81 in high scores. Netizens: AI model can't avoid "internal examination"!
IBEM mathematical formula detection data set
[机缘参悟-37]:人感官系统的结构决定了人类是以自我为中心
[how to earn a million passive income]
Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
Static linked list (subscript of array instead of pointer)
How to promote the progress of project collaboration | community essay solicitation
Software testing is so hard to find, only outsourcing offers, should I go?
【电脑插入U盘或者内存卡显示无法格式化FAT32如何解决】
Field problems in MySQL
如何使用lxml判断网站公告是否更新
[technology development-24]: characteristics of existing IOT communication technology
Use and design of Muduo buffer class
Flutter dynamic | fair 2.5.0 new version features
Summary of common error reporting problems and positioning methods of thrift
Depth and breadth first traversal of tree (regardless of binary tree)
[技術發展-24]:現有物聯網通信技術特點
项目协作的进度如何推进| 社区征文