有人可以解释一下 ARM 中的分支操作码吗? [英] Can someone explain the branch opcode in ARM?

查看:17
本文介绍了有人可以解释一下 ARM 中的分支操作码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个操作码来跳转到一个地址.

I'm trying to create an opcode to jump to an address.

我查看了手册,我看到:

I looked in the manual and I see:

B<c> <label>

31 30 29 28 | 27 26 25 24 | 23 ................. 0
    cond      1  0  1  0          imm24

我不明白 condimm24 是什么.我将如何创建一个操作码来分支到某个地址,例如分支到 0xbeffffbc?

I don't understand what cond and imm24 are. How would I go about creating an opcode to branch to some address, for example branch to 0xbeffffbc?

推荐答案

B 是一个 相对 分支,最大可达 +/-32MB.立即数编码目标地址相对于当前 PC 的有符号偏移量(即这条指令 + 8)——注意这个偏移量是以 words 计算的,而不是字节;由于指令总是字对齐的,因此任何偏移量的底部两位将始终为 00,因此在编码中是隐式的.

B is a relative branch of up to +/-32MB. The immediate encodes the signed offset of the target address from the current PC (i.e. this instruction + 8) - note that this offset is counted in words, not bytes; since instructions are always word-aligned, the bottom two bits of any offset will always be 00 and are thus made implicit in the encoding.

cond 与大多数其他 ARM 指令中的谓词字段相同.如果您已经到了探索指令编码的地步,您可能应该已经意识到这一点 - ARM ARM 的条件执行"部分(我手头的 v7A/R 版本中的 A8.3 部分)有完整的详情.

cond is the same predicate field as in most other ARM instructions. If you've got to the point of poking around instruction encodings you probably should be aware of that already - the "Conditional Execution" section of the ARM ARM (section A8.3 in the v7A/R edition I have handy) has the complete details.

ARM ARM 的典型烦恼是,虽然编码字段和它们代表的值在指令描述中进行了描述,但有时您确实必须交叉引用伪代码以弄清楚到底是什么继续.

The typical annoyance with the ARM ARM is that whilst the encoding fields and the values they represent are described in the instruction descriptions, you do sometimes have to cross-reference the pseudocode to figure out exactly what's going on.

这篇关于有人可以解释一下 ARM 中的分支操作码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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