|Home > Floating-point Support > Controlling the floating-point environment > __fp_status()|
Previous versions of the ARM libraries implemented a function
__fp_status that manipulated a status
word in the floating-point environment. This is the same as
uses an older-style status word layout. The ARM compiler still supports
__fp_status function for backwards compatibility.
__fp_status has the following prototype:
unsigned int __fp_status(unsigned int mask, unsigned int flags);
The layout of the status word as seen by
__fp_status is shown
in Figure 4.2.
The fields in Figure 4.2 are as follows:
Bits 0 to 4 are the sticky flags, as described in __ieee_status().
Bits 8 to 12 (values
control various aspects of the FPA floating-point. The FPA architecture
is obsolete and is not supported by RVCT. Any attempt to write to
these bits is ignored.
Bits 16 to 20 (values
are the exception masks, as described in __ieee_status(), but in a different place.
Bits 24 to 31 contain the system ID that cannot
be changed. It is set to
0x40 for software floating-point,
0x80 or above for hardware floating-point,
1 if a hardware
floating-point environment is being faked by an emulator.
R are reserved. They
cannot be written to by the
and you must ignore anything you find in them.
The rounding mode cannot be changed with the
In addition to defining the
stdlib.h also defines some constants to
be used for the arguments:
#define __fpsr_IXE 0x100000 #define __fpsr_UFE 0x80000 #define __fpsr_OFE 0x40000 #define __fpsr_DZE 0x20000 #define __fpsr_IOE 0x10000 #define __fpsr_IXC 0x10 #define __fpsr_UFC 0x8 #define __fpsr_OFC 0x4 #define __fpsr_DZC 0x2 #define __fpsr_IOC 0x1
For example, to trap the Invalid Operation exception and untrap all other exceptions, you would do:
__fp_status(_fpsr_IXE | _fpsr_UFE | _fpsr_OFE | _fpsr_DZE | _fpsr_IOE, _fpsr_IOE);
To untrap the Inexact Result exception:
To clear the Underflow sticky flag: