当前位置:网站首页>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]
边栏推荐
- Another industry has been broken by Chinese chips. No wonder the leading analog chip companies in the United States have cut prices and sold off
- Complete deep neural network CNN training with tensorflow to complete picture recognition case 2
- Flutter动态化 | Fair 2.5.0 新版本特性
- Swiftui development experience: the five most powerful principles that a programmer needs to master
- Realize the recognition and training of CNN images, and process the cifar10 data set and other methods through the tensorflow framework
- Qt学习17 对话框及其类型
- Complete DNN deep neural network CNN training with tensorflow to complete image recognition cases
- Brief analysis of tensorboard visual processing cases
- Comprehensive evaluation of double chain notes remnote: fast input, PDF reading, interval repetition / memory
- Unity Render Streaming通过Js与Unity自定义通讯
猜你喜欢

Logback log sorting

User and group command exercises

Conversion function and explicit

Use and design of Muduo buffer class

HALCON联合C#检测表面缺陷——HALCON例程autobahn

SQL Injection (GET/Search)

Unable to stop it, domestic chips have made another breakthrough, and some links have reached 4nm

Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station

Use vscode to view hex or UTF-8 codes

如何使用lxml判断网站公告是否更新
随机推荐
Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
实现CNN图像的识别和训练通过tensorflow框架对cifar10数据集等方法的处理
IBEM 数学公式检测数据集
Students who do not understand the code can also send their own token, which is easy to learn BSC
Error handling when adding files to SVN:.... \conf\svnserve conf:12: Option expected
Flutter动态化 | Fair 2.5.0 新版本特性
Unity render streaming communicates with unity through JS
[technology development-24]: characteristics of existing IOT communication technology
SQL Injection (POST/Search)
Unity Render Streaming通过Js与Unity自定义通讯
Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware
Libuv Library - Design Overview (Chinese version)
静态链表(数组的下标代替指针)
SQL Injection (GET/Select)
使用tensorflow进行完整的DNN深度神经网络CNN训练完成图片识别案例
项目协作的进度如何推进| 社区征文
Several common optimization methods matlab principle and depth analysis
Windos creates Cordova prompt because running scripts is prohibited on this system
Static linked list (subscript of array instead of pointer)
MySQL installation, uninstallation, initial password setting and general commands of Linux