| |||||||||||||
On-Line Manuals RealView Compiler User's Guide | Named register variables
The compiler enables you to access registers of an ARM architecture‑based processor using named register variables. Named register variables are declared by combining the register keyword with the
register int foo __asm("r0");
declares A typical use of named register variables is to access bits in the Application Program Status Register (APSR). Example 3-3 shows the use of named register variables to set the saturation flag Example 3.2. Setting bits in the APSR using a named register variable
#ifndef __BIG_ENDIAN // bitfield layout of APSR is sensitive to endianness
typedef union
{
struct
{
int mode:5;
int T:1;
int F:1;
int I:1;
int _dnm:19;
int Q:1;
int V:1;
int C:1;
int Z:1;
int N:1;
} b;
unsigned int word;
} PSR;
#else /* __BIG_ENDIAN */
typedef union
{
struct
{
int N:1;
int Z:1;
int C:1;
int V:1;
int Q:1;
int _dnm:19;
int I:1;
int F:1;
int T:1;
int mode:5;
} b;
unsigned int word;
} PSR;
#endif /* __BIG_ENDIAN */
register PSR apsr __asm("apsr");
void set_Q(void)
{
apsr.b.Q = 1;
}
| ||||||||||||
| |||||||||||||