This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How many ways to set a register 32 bit value?

Hi,

I find Arm has 16 bit immediate value load to register instruction, but it has no instruction to load 32 bit value to register. I am new to asm level programming. How many ways to load a register to a desired value for an Arm CPU?

thanks,

Parents
  • As ARM instructions are 32-bits the short answer is "you can't"

    However, one of the best options is to use the format:

    LDR Rn, =<constant>

    The assembler will then work out whether it can use a MOV, MVN or LDR from a literal pool,

    for example:

    LDR R0, =0xFFFF43FF

    should resolve to

    MVN R0, #0xBC00

    If the value can't be resolved this way, then it will use a relative load from a literal pool, e.g.

    LDR Rn, [pc, #<offset>]

    DCD <constant>

Reply
  • As ARM instructions are 32-bits the short answer is "you can't"

    However, one of the best options is to use the format:

    LDR Rn, =<constant>

    The assembler will then work out whether it can use a MOV, MVN or LDR from a literal pool,

    for example:

    LDR R0, =0xFFFF43FF

    should resolve to

    MVN R0, #0xBC00

    If the value can't be resolved this way, then it will use a relative load from a literal pool, e.g.

    LDR Rn, [pc, #<offset>]

    DCD <constant>

Children