微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ARM 中的指令回写

如何解决ARM 中的指令回写

ARM 参考手册指出:

如果 Load 指令指定回写并且正在加载的寄存器也是基址寄存器,则行为是 CONSTRAINEDUNPREDICTABLE

在这种情况下,“回写”一词是什么意思?

解决方法

“ldr(立即)”指令有三种形式:

ldr x0,[x1,8]
ldr x0,8]!
ldr x0,[x1],8

第一个应该很明显,并且是“常规”语法。
第二个称为预索引,相当于:

add x1,x1,8
ldr x0,[x1]

第三个称为后索引,相当于:

ldr x0,[x1]
add x1,8

手册中提到的情况是这样的:

ldr x0,[x0,[x0],8

在那种情况下(来自 the G.a version 的第 K1-8255 页):

CONSTRAINED UNPREDICTABLE behavior

If the instruction encoding specifies pre-indexed addressing or post-indexed
addressing,and n == t && n != 31,then one of the following behaviors must
occur:

•   The instruction is UNDEFINED.
•   The instruction executes as a NOP.
•   The instruction performs the load using the specified addressing mode,and the base register is set to an UNKNOWN value. In addition,if an
    exception occurs during such an instruction,the base register might be
    corrupted so that the instruction cannot be repeated.
•   For execution at EL0 or EL1,when EL2 is implemented and enabled for the
    current Security state and HCR_EL2.TIDCP is 1,the instruction is trapped
    to EL2 with EC value 0x0.

------ Note ------------
Pre-indexed addressing and post-indexed addressing imply writeback.
------------------------

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。