【arm】ARM32和AARCH64的几点区别

本文介绍了ARM32和AARCH64在指令编码长度、当前指令地址、形参访问方式、AARCH64中向量寄存器元素访问及立即数使用等方面的区别。在ARM32中,当前指令地址通常是pc-8或pc-4,而在AARCH64中则是pc本身。形参传递方面,ARM32前4个参数通过r0-r3,超出部分通过sp访问;AARCH64前8个参数通过x0-x7,其余通过sp访问。AARCH64的< Vn >.< Ts >[< index2 >]用于访问矢量寄存器元素,imm的取值范围需根据指令而定。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Date: 2018.11.11

学习参考: https://blog.csdn.net/listener51/article/details/82856001

1、指令编码长度
A32模式(ARM instruction sets),指令固定的编码长度为32bit
T32模式(Thumb instruction sets),指令可以编码成16bit长,也可编码成32bit长
A64模式(AArch64 instruction sets),指令固定的编码长度为32bit
2、当前指令的地址

在ARM32状态下,当前执行指令的地址通常是pc-8,而在Thumb状态下通常是pc-4。
参考地址:http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0013d/index.html 程序计数器(pc)

拿ARMv7三级流水线做示例,如图,假设add指令fetch时,指令地址为pc1; add指令decode时,下一条指令sub又进入fetch阶段,此时pc2 = pc1 + 4; add指令execute时,sub指令后的cmp油进入fetch阶段,此时pc = pc2 + 4, 因此add指令执行时真正的pc地址pc1 = pc-8。
在这里插入图片描述
参考: https://blog.csdn.net/lee244868149/article/details/49488575/

在AARCH64状态下,当前执行指令的地址通常是pc。
英文原文:

Program counter
 The current Program Counter (PC) cannot be referred to by number as if part of the general register file and therefore cannot be used as the source or destination of arithmetic instructions, or as the base, index or transfer register of load and store instructions.
 The only instructions that read the PC are those whose function it is to compute a PC-relative address (ADR, ADRP, literal load, and direct branches), and the branch-and-link instructions that store a return address in the link register (BL and BLR). The only way to modify the program counter is using branch, exception generation and exception return instructions.
 Where the PC is read by an instruction to compute a PC-relative address, then its value is the address of that instruction. Unlike A32 and T32, there is no implied offset of 4 or 8 bytes.

参考: http://infocenter.arm.com/help/index.jsptopic=/com.arm.doc.den0024a/ch05s01s03.html 5.1.3. Registers

3、形参超过指定通用寄存器个数的访问方法

arm32下,前4个参数是通过r0~r3传递,第4个参数需要通过sp访问,第5个参数需要通过sp + 4 访问,第n个参数需要通过sp + 4*(n-4)访问。

arm64下,前8个参数是通过x0~x7传递,第8个参数需要通过sp访问,第9个参数需要通过sp + 8 访问,第n个参数需要通过sp + 8*(n-8)访问。

4、aarch64下< Vn >.< Ts >[< index2 >]的用法

示例:

 mov < Vd >.< Ts >[< index1 >], < Vn >.< Ts >[< index2 >]

其中Ts的值需要注意,只能是以下情况之一:

  • B :8bit
  • H:16bit
  • S :32bit
  • D: 64bit

注意:不要将Ts写成8B、2s等,因为是取矢量寄存器(Vn)中的元素。

5、aarch64下imm需注意的地方

示例:

cmp < Wn|WSP>, #< imm> {, < shift>}

其中imm是无符号立即数,取值范围[0, 4095]。

注意:在使用立即数的时候,需要看指令所支持的立即数范围。不同指令中立即数的取值范围可能不同。


THE END!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值