[register]-ARMV8-aarch64-通用寄存器介绍

本文介绍了ARMv8/ARMv9架构中的通用寄存器,包括X0-X30、SP、PC和XZR等。详细阐述了不同寄存器的用途:X0-X7作为参数传递和返回结果;X9-X15是caller-saved临时寄存器,可直接使用;X19-X29为callee-saved寄存器,需保存和恢复;X8、X16-X18、X29、X30则有特定功能,如X8用于间接结果,X16和X17为IP寄存器,X29是帧指针,X30为链接寄存器。

快速链接:
.
👉👉👉 个人博客笔记导读目录(全部) 👈👈👈

在这里插入图片描述

1、通用寄存器

ARMv8有31个通用寄存器X0-X30, 还有SP、PC、XZR等寄存器
下面详细介绍写这些通用寄存器(general-purpose registers):

  • (1)、X0-X7 Argument registers
    用于参数传递

These are used to pass parameters to a function and to return a result. They can be used as scratch registers or as caller-saved register variables that can hold intermediate values within a function, between calls to other unctions. The fact that 8 registers are available for passing parameters reduces the need to spill parameters to the stack when compared with AArch32

  • (2)、X9-X15 Caller-saved temporary registers
    在子函数中使用这些寄存器时,直接使用即可, 无需save/restore. 在汇编代码中x9-x15出现的频率极低

If the caller requires the values in any of these registers to be preserved across a call to another function, the caller must save the affected registers in its own stack frame. They can be modified by the called subroutine ithout the need to save and restore them before returning to the caller.

  • (3)、X19-X29 Callee-saved registers (X19-X29)
    在callee子函数中使用这些寄存器时,需要先save这些寄存器,在退出子函数时再resotre

These registers are saved in the callee frame. They can be modified by the called subroutine as long as they are saved and restored before returning.

  • (4)、X8, X16-X18, X29, X30 Registers with a special purpose
    这些都是特殊用途的寄存器

• X8 is the indirect result register. This is used to pass the address location of an indirect result, for example, where a function returns a large structure.
• X16 and X17 are IP0 and IP1, intra-procedure-call temporary registers. These can be used by call veneers and similar code, or as temporary registers for intermediate values between subroutine calls. They are corruptible by a function. Veneers are small pieces of code which are automatically inserted by the linker, for example when the branch target is out of range of the branch instruction.
• X18 is the platform register and is reserved for the use of platform ABIs. This is an additional temporary register on platforms that don’t assign a special meaning to it.
• X29 is the frame pointer register (FP).
• X30 is the link register (LR).

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Arm精选

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值