当前位置:网站首页>What are the functions of arm64 assembly that need attention?

What are the functions of arm64 assembly that need attention?

2022-06-25 11:06:00 Hua Weiyun

1. What is the function call convention ?

ARM64 It uses ATPCS(ARM-Thumb Procedure Call Standard/ARM-Thumb Procedure call standard ) Function calling convention for .

2. What instructions do functions need to use ?
B: Jump unconditionally , It's usually inside a function if、switch The jump of conditional judgment
Bl: Jump with function return value , It's usually used to call other functions .RET: Subroutines return instructions , The return address is saved in... By default X30 register (LR Link Register )
LR: Save the next instruction that needs to be executed after the end of the subroutine
PC: Represents the address of the currently executed instruction .

3. How to store and pass the parameters of a function ?
3.1. Usually, the parameters of a function are stored in X0-X7(32 Bitwise is W0-W7) this 8 A register , If the function parameter exceeds 8 individual , Then you need to use stack storage to store parameters .
3.2. If the function parameter is less than 8 If there are two parameters, pass the parameters from left to right in turn , If more than 8 Then the stack is loaded from right to left .
3.3 Function 8 Parameters and 9 The details of each parameter ( However, in the development process, the parameters exceed 8 There are relatively few cases , So in the reverse process, this excess 8 The number of parameters will be less )
3.3.1 Function with eight arguments , Use register directly W0-W7 Express

    Source code :

image.png

   ARM64 Assembly code :

image.png

原网站

版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206251046553862.html