How can ARM's MOV instruction work with a large number as the second operand?

前端 未结 7 1994
陌清茗
陌清茗 2020-12-28 17:23

I just begin to study ARM assembly language, and am not clear about how to use MOV to transfer an immediate number into a register.

From both the ARM reference manual

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-28 17:44

    A single ARM instruction can only encode an immediate constant that can be represented as an 8-bit immediate value, shifted by any even power of two.

    However, there is also a MVN instruction, which is like MOV but inverts all the bits. So, while MOV R2, #0xFFFFFFFF cannot be encoded as a MOV instruction, it can be encoded as MVN R2, #0. The assembler may well perform this conversion for you.

提交回复
热议问题