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

前端 未结 7 1996
陌清茗
陌清茗 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 18:07

    MOV instruction can either accept imm16 value or Operator2 value (due to instruction length opposed to memory alignment), which must conform any of the following rules (copied from CortexM instruction set manual, X and Y is any hex-value):

    • Any constant that can be produced by shifting an 8-bit value left by any number of bits within a 32-bit word.
    • Any constant of the form 0x00XY00XY .
    • Any constant of the form 0xXY00XY00 .
    • Any constant of the form 0xXYXYXYXY .

    This is why 0xFFFFFFFF is accepted (conforms 4th rule).

    If you wish to assemble your own 32 bit constant, you can use instruction MOVT, which writes into the upper half of a register.

    0 讨论(0)
提交回复
热议问题