assembly - STP 中的寄存器存储顺序

标签 assembly arm arm64

在 AArch64 程序集中,以下行

stp x25, x30, [sp,#48]

在 sp+48 处存储 x25,在 sp+56 处存储 x30,对吗?

最佳答案

是的。来自 this manual ,第 C6-1237 页及以下:

Signed offset

[...]

64-bit variant

Applies when opc == 10.

STP <Xt1>, <Xt2>, [<Xn|SP>{, #<imm>}]
Decode for all variants of this encoding

boolean wback = FALSE;
boolean postindex = FALSE;
[...]

Shared decode for all encodings

[...]
integer n = UInt(Rn);
integer t = UInt(Rt);
integer t2 = UInt(Rt2);
[...]
integer scale = 2 + UInt(opc<1>);
integer datasize = 8 << scale;
bits(64) offset = LSL(SignExtend(imm7, 64), scale);
[...]

Operation for all encodings

constant integer dbytes = datasize DIV 8;

[...]

if n == 31 then
    CheckSPAlignment();
    address = SP[];
else
    address = X[n];

if !postindex then
    address = address + offset;

[...]
data1 = X[t];
[...]
data2 = X[t2];

Mem[address, dbytes, AccType_NORMAL] = data1;
Mem[address+dbytes, dbytes, AccType_NORMAL] = data2;


让我们从头到尾了解一下。您的 stp x25, x30, [sp,#48] 是一个 64 位有符号偏移量 stp,它解码为:

n = 31
t = 25
t2 = 30
scale = 3 // since opc = 0b10
datasize = 64
offset = 48

将其插入到操作伪代码中,用变量替换它们的值,您就可以有效地得到:

CheckSPAlignment();
Mem[SP[] + 48, 8, AccType_NORMAL] = X[25];
Mem[SP[] + 56, 8, AccType_NORMAL] = X[30];

关于assembly - STP 中的寄存器存储顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57153954/

相关文章:

汇编 - CMP 后的 JZ 指令

assembly - 旋转指令(x86 上的 ROL、RCL)的用途是什么?

c++ - 将源代码与反汇编代码匹配

assembly - 将多个变量连接成一个字符串

iphone - 如何在 iPhone 上使用 ARMv6 优化的 OpenMAX DL 库

为 ARM 处理器编译基本 C 文件

gcc - gcc-arm-linux-gnueabi 是否为 64 位目标构建?

linux - QEMU aarch64 没有命中断点

ios - Podfile 错误 : Undefined Symbols for Architecture arm64

assembly - 如何确定 ARMv8 处理器是否支持 AArch32 执行状态?