作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在 arm 上解码 blx 指令,我在这里找到了一个很好的答案:
Decoding BLX instruction on ARM/Thumb (IOS)
但在我的情况下,我一步一步地遵循这个提示,得到了错误的结果,谁能告诉我为什么?
这是我的测试:
.plt: 000083F0 sub_83F0 ...
...
.text:00008436 FF F7 DC EF BLX sub_83F0
F7 FF EF DC
11110 1 1111111111 11 1 0 1 1111101110 0
S imm10H J1 J2 imm10L
I1 = NOT(J1 EOR S) = 1
I2 = NOT(J2 EOR S) = 1
imm32 = SignExtend(S:I1:I2:imm10H:imm10L:00)
= SignExtend(1111111111111111110111000)
= SignExtend(0x1FFFFB8)
= ?
最佳答案
当 BLX 的目标是 32 位 ARM 代码时,BLX
中编码的立即数指令添加到 align(PC,4)
,不是 PC
的原始值.
PC
在 BLX
执行期间指令是 0x8436 + 4 == 0x843a
由于ARM管道align(0x843a, 4) == 0x8438
0x00008438 + 0ffffffb8 == 0x83f0
<label>
的汇编语法中提到了这一点。部分指令:
For BLX (encodings T2, A2), the assembler calculates the required value of the offset from the Align(PC,4) value of the BLX instruction to this label, then selects an encoding that sets imm32 to that offset.
if ConditionPassed() then
EncodingSpecificOperations();
if CurrentInstrSet == InstrSet_ARM then
next_instr_addr = PC - 4;
LR = next_instr_addr;
else
next_instr_addr = PC;
LR = next_instr_addr<31:1> : ‘1’;
if toARM then
SelectInstrSet(InstrSet_ARM);
BranchWritePC(Align(PC,4) + imm32); // <--- alignment of the current PC when BLX to non-Thumb ARM code
else
SelectInstrSet(InstrSet_Thumb);
BranchWritePC(PC + imm32);
关于arm - 在 ARM/Thumb(Android) 上解码 BLX 指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17398343/
我是一名优秀的程序员,十分优秀!