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

two’s complement

 How to load the two’s complement representation of -1 into Register 3 using one instruction?

i am working on ARM7 and NXP processor.

Parents
  • If you use MOV the assembler will try various tricks to see if it can be done using shifting or using MVN

    MOV r3, #-1

    the assembler will turn this into

    MVN r3, #0

    which you can also write.

    See the armasm documentation about loading literals, one can also use LDR r3,=-1 which will load the value from a literal pool if it can't be done in one instruction inline.

    Using MOV32 r3,-1 will generate two instructions

Reply
  • If you use MOV the assembler will try various tricks to see if it can be done using shifting or using MVN

    MOV r3, #-1

    the assembler will turn this into

    MVN r3, #0

    which you can also write.

    See the armasm documentation about loading literals, one can also use LDR r3,=-1 which will load the value from a literal pool if it can't be done in one instruction inline.

    Using MOV32 r3,-1 will generate two instructions

Children