Keil Logo


Information in this article applies to:

  • AARM Macro Assembler
  • CARM Compiler (in-line Assembler)
  • Other ARM Development Tools
  • ARM Instruction Set


I am new to the ARM processor family and I struggle with in-line assembly. The following in-line assembly instruction in the Keil CARM compiler generates an error message.

  void main (void)  {
    __asm       {  MOV R0,#0xE0028004 }

The compiler displays:

error C197: inline-asm: Invalid or out of range value

Other values, such as 0xE0000004 and 0xE0000014 do not produce this error. What can be the problem?


The op2 field in the ARM instructions allows only 8-bit constants that may be rotated by an even number (0, 2, 4, 6, .., 30). Valid constants are: #0x12, #0xFF, #0x2FC0, #0xC000003F. Invalid constants are: #0x1FF, #0x1FE, #0x1234. These numbers cannot be represented in an 8-bit value that is rotated as described above. Such constants must be loaded via a so-called memory pool and the LDR Rd,[PC, offset] instruction.

The ARM tools offer automated ways to create memory pool entries. The assembly instruction LDR Rd,=value generates the instruction MOV Rd,#value for constants that can be represented by 8-bit rotated values. For other values it is translated to LDR Rd,[PC, offset] with a corresponding memory pool entry.

Therefore you may simply use the form LDR Rd,=value instead of MOV Rd,#value.


  void main (void)  {
    __asm       {  LDR R0,=0xE0028004 }



Last Reviewed: Monday, February 4, 2019

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.