Decoding BLX instruction on ARM/Thumb (IOS)

隐身守侯 提交于 2019-12-04 13:13:16
Stephen Canon

First, the instruction is being printed as two little-endian 16-bit fields. To match the byte ordering in the ARM reference manual, you need to byteswap each of the fields. For the first instruction, that gives:

F0 02 ED B2

or

11110000000000101110110110110010.

This is encoding T2 of the BLX instruction. Breaking this into the fields identified in the ARM:

11110  0  0000000010  11  1  0  1  1011011001  0  
       S    imm10H        J1    J2   imm10L

Then follow the instructions for interpretation of the fields:

I1 = NOT(J1 EOR S) = 0
I2 = NOT(J2 EOR S) = 0

imm32 = SignExtend(S:I1:I2:imm10H:imm10L:00)
      = SignExtend(0000000000010101101100100)
      = 0x00002b64

Which is precisely 0x5FE4 - 0x3480 (remember, the PC is 4 bytes ahead in Thumb/Thumb 2).

I trust you can work through the second example yourself.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!