ARM Technical Support Knowledge Articles

IN-LINE ASSEMBLER ACCESS TO SPSR

Applies to: RealView C Compiler

Answer


Information in this article applies to:


QUESTION

The following code was written for the ARM ADS Compiler to disable an interrupt:

__asm
  {
  MRS  R0,SPSR
  ORR  R0,R0,#0x80    // disable interrupt
  MSR  SPSR_c,R0
}

When I try to re-compile it with the current version of the RealView Compiler, I get several error messages:

error C197: inline-asm: Syntax error
*** MRS R0, SPSR
error C197: inline-asm: undefined identifier
*** MRS R0, SPSR

Is there a solution to this problem?

ANSWER

Access to the SPSR registers is no longer allowed, since there are collisions with code optimization. Instead, use the following intrinsic functions:

void __disable_irq(void);
void __enable_irq(void);
void __disable_fiq(void);
void __enable_fiq(void);

These functions are designed for enabling and disabling interrupts and you need to replace the in-line assembler.

Note that they only work in Supervisor mode. For classic microcontroller applications implement SWI functions as explained in ARMCC: MODIFY IRQ FLAG TO DISABLE/ENABLE INTERRUPTS.

MORE INFORMATION

SEE ALSO

Article last edited on: 2010-03-23 09:13:40

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