ldr 和 ldr.w 的区别 [英] difference between ldr and ldr.w

查看:44
本文介绍了ldr 和 ldr.w 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近不得不调试一个 MachO 二进制文件,我遇到了以下指令:-

I recently had to debug a MachO binary and I came across the following instruction :-

ldr.w r4, [r1, r0, lsl #2]

我知道 ldr r4, [r1, r0, lsl #2] 将 r0 向左移动两次,将其添加到 r1 并取消引用结果.

I understand that ldr r4, [r1, r0, lsl #2] shifts r0 to the left two times, adds it to r1 and dereferences the result.

ldr.w 有什么不同?

How is ldr.w different?

推荐答案

.W 是一个可选的指令宽度说明符.它不会影响指令本身的行为,它只是确保生成 32 位指令.请参阅 infocenter.arm.com详情:

.W is an optional instruction width specifier. It doesn't affect the behaviour of the instruction as such, it just ensures that a 32 bit instruction is generated. See infocenter.arm.com for details:

Thumb-2 中的 LDR(相对于 PC)您可以使用 .W 宽度说明符强制 LDR 在 Thumb-2 代码中生成 32 位指令.LDR.W 始终生成 32 位指令,即使使用 16 位 LDR 可以达到目标.对于前向引用,不带 .W 的 LDR 总是在 Thumb 代码中生成 16 位指令,即使这会导致使用 32 位 Thumb-2 LDR 指令可以达到的目标失败.

LDR (pc-relative) in Thumb-2 You can use the .W width specifier to force LDR to generate a 32-bit instruction in Thumb-2 code. LDR.W always generates a 32-bit instruction, even if the target could be reached using a 16-bit LDR. For forward references, LDR without .W always generates a 16-bit instruction in Thumb code, even if that results in failure for a target that could be reached using a 32-bit Thumb-2 LDR instruction.

这篇关于ldr 和 ldr.w 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆