函数调用的arm汇编实现

看《ARM System Developer's Guide: Designing and Optimizing System Software》中5.5节function call,讲的不是很具体

发现网上的这份资料讲解非常好,以arm64为target,言简意赅,下面是目录

(1) Calling and returning
How does caller function jump to callee function?
How does callee function jump back to the right place in caller function?

(2) Passing arguments
How does caller function pass arguments to callee function?

注释:这里没有讲到 多个参数传递(参数个数大于某个数量,因为arm传参标准规定,只能用寄存器的几个作为参数传递,参数再多,就需要用另外的机制了)

和 结构体传递(将多个相关的参数封装成结构体,然后传结构体的地址,从而就可以不使用前面说的 多个参数传递行为)

(3) Storing local variables
Where does callee function store its local variables?

(4) Returning a value
How does callee function send return value back to caller function?
How does caller function access the return value?

(5) Optimization
How do caller and callee function minimize memory access?

 

pdf链接:https://www.cs.princeton.edu/courses/archive/spr19/cos217/lectures/15_AssemblyFunctions.pdf

pdf内容如下

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2022-03-18 09:31  midhillzhou  阅读(329)  评论(0编辑  收藏  举报