CPSR to C variable

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?

If you know the physical memory address of the CPSR you can do something like this:

#define REG_CPSR      0x0010

//other code goes here somewhere
int *ptr = REG_CPSR;

I’m rusty at pointers at the moment, but I think you get the idea…

I got it figured out. My problem was the code was being built in 16 bit mode with thumb instructions which prohibited the access for CPSR

If I declare some volatile global int I can access it no problem:

asm("  ldr a2, CON1");          // load CON1 (cpsrstat) into a2 
asm("  mrs r3, cpsr");           // load CPSR into r3
asm("  strh r3, [a2, #0]");     // store r3 into a2 (0 offset)

I bitshift my new C variable to account for FIQ and IRQ disable and away I go