ARM v8 中的 LDUR 和 STUR [英] LDUR and STUR in ARM v8
问题描述
我上过几门涉及 ARMv8 汇编的课程,但是两位老师都以不同的方式描述了 LDUR/STUR 指令,现在我已经迷失了方向.有人可以帮忙澄清一下吗?
I've had a couple of courses that touched on ARMv8 assembly, but both teachers described LDUR/STUR instructions a different way and now I've become pretty lost. Can someone help to clarify?
如果我有指令:
LDUR R3, [R1, #8]
我会将答案放在 R3 中,但是我从 R1 中得到了什么以及偏移量如何运作?这就像一个逻辑转变吗?ARM 手册将其描述为字节偏移".但随后没有描述该偏移量如何在 R1 上发挥作用.我是否移动了存储在 R1 中的值(比如 R1 的值是 50),还是我需要考虑 R1 之外的内存地址?其他消息来源说我需要以某种方式将 R1 视为一个数组?
I'll be putting the answer in R3, but what am I taking from R1 and how does the offset operate? Is it like a logical shift? The ARM manual describes it as "byte offset" but then doesn't describe how that offset functions on R1. Do I shift the value stored in R1 (say R1 has value 50 in it) or is there a memory address outside of the R1 that I need to be thinking about? Other sources say I need to think of R1 as an array somehow?
推荐答案
LDUR 是 Load (unscaled) Register.它从一个地址加上一个寄存器的偏移量加载一个值(32 位或 64 位).unscaled
意味着在机器代码中,偏移量将不用像 ldr
使用的缩放偏移量编码,即不会应用移位到立即偏移位.偏移量(simm 有符号立即数)将被添加到基址寄存器 Xn|SP.
LDUR is Load (unscaled) Register. It loads a value (32-bits or 64-bits) from an address plus an offset to a register. unscaled
means that in the machine-code, the offset will not be encoded with a scaled offset like ldr
uses, i.e. no shift will be applied to the immediate offset bits. The offset (simm signed immediate) will be added to the base register Xn|SP.
因此,与 ldr
这些是 LDUR 的原型:
These are the prototypes for LDUR:
-- loads a 32-bit value
LDUR <Wt>, [<Xn|SP>{, #<simm>}]
-- loads a 64-bit value
LDUR <Xt>, [<Xn|SP>{, #<simm>}]
STUR 是存储(未缩放)寄存器,工作方式相同,但它将寄存器中的值存储到内存中.
STUR is Store (unscaled) Register and works in the same way but it stores the value in a register to memory.
这些是 STUR 的原型:
These are the prototypes for STUR:
-- stores a 32-bit register
STUR <Wt>, [<Xn|SP>{, #<simm>}]
-- stores a 64-bit register
STUR <Xt>, [<Xn|SP>{, #<simm>}]
LDUR/STUR 允许访问与操作数的大小不对齐的 32/64 位值.例如,存储在地址 0x52 处的 32 位值.
LDUR/STUR allow accessing 32/64-bit values when they are not aligned to the size of the operand. For example, a 32-bit value stored at address 0x52.
在你的例子中,
LDUR R3, [R1, #8]
这条指令会将R1
指向的值加上8
个字节加载到R3
.这就是 ARM 参考手册中 byte offset
的意思.因此,如果 R1
持有值 0x50
,这将加载存储在地址 0x58
的值.R1
的值不会被修改.
this instruction will load to R3
the value pointed by R1
plus 8
bytes. This is what the ARM Reference Manual means by byte offset
.
So if R1
holds the value 0x50
, this will load the value stored at address 0x58
. The value of R1
will not be modified.
指令 LDR R3, [R1, #8]
(LDR (immediate) Unsigned offset 变体)产生相同的操作,然而,原型是不同的:
The instruction LDR R3, [R1, #8]
(LDR (immediate) the Unsigned offset variant) produces the same operation, however, the prototype is different:
-- loads a 32-bit value
LDR <Wt>, [<Xn|SP>{, #<pimm>}]
-- loads a 64-bit value
LDR <Xt>, [<Xn|SP>{, #<pimm>}]
直接偏移pimm不同,LDUR使用simm.这意味着以不同的方式解释偏移量.第一个 (pimm) 是一个正偏移量,其范围对于 32 位变体和 64 位变体是不同的.
The immediate offset pimm is different, LDUR uses a simm. This means that the offset is interpreted in a different way. The first (pimm) is a positive offset and its range is different for the 32-bit variant and the 64-bit variant.
在 32 位版本中:
- 范围从0到16380,只能是4的倍数
在 64 位版本中:
- 范围从 0 到 32760,并且只能是 8 的倍数
这意味着 LDUR 和 LDR(立即)的一些偏移组合将产生相同的操作.
这篇关于ARM v8 中的 LDUR 和 STUR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!