当前位置:网站首页>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]
边栏推荐
- Conversion function and explicit
- [how to solve FAT32 when the computer is inserted into the U disk or the memory card display cannot be formatted]
- SQL Injection (AJAX/JSON/jQuery)
- Flutter动态化 | Fair 2.5.0 新版本特性
- untiy世界边缘的物体阴影闪动,靠近远点的物体阴影正常
- SQL Injection (POST/Search)
- Unity Render Streaming通过Js与Unity自定义通讯
- GoLand 2021.1.1: configure the multi line display of the tab of the open file
- JVM系列——概述,程序计数器day1-1
- ThreadPoolExecutor realizes multi-threaded concurrency and obtains the return value (elegant and concise way)
猜你喜欢

Golang — 命令行工具cobra

How to use lxml to judge whether the website announcement is updated

Qt学习25 布局管理器(四)

Use and design of Muduo buffer class

AI scores 81 in high scores. Netizens: AI model can't avoid "internal examination"!

Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware

JVM系列——概述,程序计数器day1-1

【电脑插入U盘或者内存卡显示无法格式化FAT32如何解决】

MySQL installation, uninstallation, initial password setting and general commands of Linux

The latest BSC can pay dividends. Any B usdt Shib eth dividend destruction marketing can
随机推荐
Spark practice 1: build spark operation environment in single node local mode
IBEM mathematical formula detection data set
MySQL installation, uninstallation, initial password setting and general commands of Linux
Complete DNN deep neural network CNN training with tensorflow to complete image recognition cases
Internet of things completion -- (stm32f407 connects to cloud platform detection data)
SQL Injection (AJAX/JSON/jQuery)
Go language web development series 30: gin: grouping by version for routing
logback日志的整理
Box layout of Kivy tutorial BoxLayout arranges sub items in vertical or horizontal boxes (tutorial includes source code)
研发团队资源成本优化实践
栈应用(平衡符)
Go 1.16.4: manage third-party libraries with Mod
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
GoLand 2021.1.1: configure the multi line display of the tab of the open file
全面发展数字经济主航道 和数集团积极推动UTONMOS数藏市场
JSON serialization case summary
Golang - command line tool Cobra
Mastering the cypress command line options is the basis for truly mastering cypress
There is nothing new under the sun. Can the meta universe go higher?
Dynamic programming 01 knapsack and complete knapsack