ARM Technical Support Knowledge Articles

IN-LINE ASSEMBLY GENERATES ERROR C197

Applies to: CARM C Compiler

Answer


Information in this article applies to:


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

Article last edited on: 2005-04-13 08:42:01

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