Keil Logo

CARM: IN-LINE ASSEMBLY GENERATES ERROR C197


Information in this article applies to:

  • CARM All Versions

QUESTION

I have written the following C function using in-line assembly.

static void __set_cpsr(unsigned int value) {
  __asm { msr CPSR, value };
}

However, when I compile this function I get:

Error C197: inline-asm: syntax error

What is the reason for this error?

ANSWER

By default, the Keil CARM Compiler uses the Thumb mode. Therefore the ARM mode instruction msr CPSR_c,Rn is not available.

You may use the __arm function attribute to change the CPU mode to ARM. Then the instruction is accepted, but may still not produce the desired results:

static void __set_cpsr(unsigned int value) __arm {
  value = value;              // avoid warning: unused parameter
  __asm { msr CPSR_c, R0 };   // value passed in R0
}

The instruction MSR CPSR_c is disabled in User Mode. The User Mode is the standard operation mode after execution of the STARTUP code. For disabling interrupts, you should use Software Interrupt functions.

MORE INFORMATION

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Wednesday, April 13, 2005


Did this article provide the answer you needed?
 
Yes
No
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.