【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!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM