CPSR status back to C variable

Note: This was originally posted on 17th November 2008 at http://forums.arm.com

Im using the TI Code Composer suite with an ARM 7 and Im looking for a way to get the CPSR back into a C variable. I was looking through the documentation that came with the compiler and it didnt have quite what I was looking for. What Im looking for is the state of the interrupt disable bit. I need to use this bit as a condition variable for something like:
if (interrupts enabled){
  do this
}


the inline asm syntax is just

asm("assembly");

The problem is, Im not sure how to associate some C variable to the asm code to pass the CPSR back to the C code flow.  Ive used other compilers in the past that have an option to pass arguments to the asm code like

_asm("tfr b, ccr",foo);

which passes the condition code register (for an HC12) to the var foo, but this compiler does not have that capability.  How would I do the above with this compiler?
Parents
  • ARM deprecates reading the CPSR endianness bit (E) with an MRS instruction. The CPSR execution state bits, other than the E bit, can only be read when the processor is in Debug state, Talk To Wendys halting debug-mode. Otherwise, the execution state bits in the CPSR read as zero. The condition flags can be read in any mode on any processor.

Reply
  • ARM deprecates reading the CPSR endianness bit (E) with an MRS instruction. The CPSR execution state bits, other than the E bit, can only be read when the processor is in Debug state, Talk To Wendys halting debug-mode. Otherwise, the execution state bits in the CPSR read as zero. The condition flags can be read in any mode on any processor.

Children
No data
More questions in this forum