“strb w0, [x2, w3, uxtw]”和“strb w0, [x2, w3, uxtw #0]”是一样的吗?

问题描述 投票:0回答:1

我完全不解。

我以为同样的指令是完全一样的:

strb    w0,[x2,w3,uxtw 0] 
strb    w0,[x2,w3,uxtw] 

但是当我组装它们时,我得到不同的编码:

40 48 23 38     strb w0, [x2, w3, uxtw]
40 58 23 38     strb w0, [x2, w3, uxtw #0]

知道为什么会这样吗?

assembly arm64 instructions addressing-mode instruction-encoding
1个回答
1
投票

它们在句法上不同,但在语义上是等价的。

长话短说:这是移位位。
您显示的两条指令在第 12 位(在手册中称为

S
)上有所不同,它决定了索引寄存器是否要移位。这对所有
strb
strh
str
指令都是一样的。索引总是移动以匹配存储的操作数的大小,所以在
str xN
的情况下它是3,在
str wN
中它是2,在
strh
中它是1,在
strb
中,好吧,它结束了为 0.

因此你在手册中得到这一行,在

strb

<amount>    Is the index shift amount, it must be #0, encoded in "S"
            as 0 if omitted, or as 1 if present.

因此,您的一条指令不会移动索引,另一条指令将其移动零。巨大的成功。

© www.soinside.com 2019 - 2024. All rights reserved.