当前位置:网站首页>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]
边栏推荐
- Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware
- Leetcode-1175.Prime Arrangements
- Field problems in MySQL
- MySQL 数据处理值增删改
- pytorch 载入历史模型时更换gpu卡号,map_location设置
- Mobile phones and computers can be used, whole people, spoof code connections, "won't you Baidu for a while" teach you to use Baidu
- 从零开始的基于百度大脑EasyData的多人协同数据标注
- Implementation of Muduo accept connection, disconnection and sending data
- Halcon combined with C # to detect surface defects -- Halcon routine autobahn
- Go 1.16.4: manage third-party libraries with Mod
猜你喜欢

Summary of common error reporting problems and positioning methods of thrift

The latest BSC can pay dividends. Any B usdt Shib eth dividend destruction marketing can

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

Flutter动态化 | Fair 2.5.0 新版本特性
![[understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered](/img/06/b71b505c7072d540955fda6da1dc1b.jpg)
[understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered

Libuv Library - Design Overview (Chinese version)

Go language unit test 5: go language uses go sqlmock and Gorm to do database query mock

Go language unit test 3: go language uses gocovey library to do unit test

Go language web development series 30: gin: grouping by version for routing

GoLand 2021.1: rename the go project
随机推荐
Go 1.16.4: manage third-party libraries with Mod
Mobile phones and computers can be used, whole people, spoof code connections, "won't you Baidu for a while" teach you to use Baidu
GoLand 2021.1.1: configure the multi line display of the tab of the open file
Software testing is so hard to find, only outsourcing offers, should I go?
IBEM mathematical formula detection data set
Golang — template
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
How to promote the progress of project collaboration | community essay solicitation
JVM family - overview, program counter day1-1
Mycms we media mall v3.4.1 release, user manual update
Qt学习22 布局管理器(一)
GoLand 2021.1: rename the go project
Field problems in MySQL
RichView TRVStyle ListStyle 列表样式(项目符号编号)
Use and design of Muduo buffer class
Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
TensorBoard可视化处理案例简析
常见的几种最优化方法Matlab原理和深度分析
Flutter动态化 | Fair 2.5.0 新版本特性
Logback log sorting