【arm】ARM32和AARCH64的几点区别

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!

原文地址:https://www.cnblogs.com/SoaringLee/p/10532289.html