0

How to load the number 0xEFFFFFF2 to a register in ARM.
What will be the rot in this?

MVN r0, #2D1 

Is this instruction valid?

zx485
  • 28,498
  • 28
  • 50
  • 59
Umang Okate
  • 3
  • 1
  • 4
  • What have you tried and what problem have you encountered? See for example [this](https://community.arm.com/processors/b/blog/posts/how-to-load-constants-in-assembly-for-arm-architecture) page. – Jeroen Heier Feb 25 '17 at 07:13
  • I highlighted keywords and (hopefully) improved the clarity of the question. – zx485 Feb 27 '17 at 23:51

1 Answers1

0

mvn is just going to invert 0x2D1 to 0xFFFFFD2E right? You need the inverse of your desired number which is 0x1000000D right? Gnu assembler is encoding 0x2D1 the 2 means rotate right 4 and the 0xD1 is the value to rotate. you dont need to worry about that unless you are making the machine code yourself you dont need to put the 0x2D1 in the assembly language put the number you want either do this

mov r0,#0xEFFFFFF2

or

mvn r0,#0x1000000D

or

ldr r0,=0xEFFFFFF2

An assembler like gnu assembler will attempt to find a single instruction that will solve the mov in this case it chooses mvn r0,#0x1000000D, some other assemblers may not try and simply tell you your constant is bad for the mov instruction forcing you to do the mvn yourself. Or you can do the mvn yourself. For gnu assembler the third choice it will try mov, mvn, and if neither work for that constant then it will place the value nearby and do a pc relative load (consuming two words of .text space).

old_timer
  • 69,149
  • 8
  • 89
  • 168