ARM Technical Support Knowledge Articles

MOV #CONSTANT GENERATES C197 ERROR MESSAGE

Applies to: ARM Development Tools

Answer


Information in this article applies to:


QUESTION

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?

ANSWER

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.

Example:

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

MORE INFORMATION

SEE ALSO

Article last edited on: 2010-03-24 10:21:02

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential