5.2. The software floating-point library, fplib

When programs are compiled to use a floating-point coprocessor, they perform basic floating-point arithmetic (for example addition and multiplication) by means of floating-point machine instructions for the target coprocessor. When programs are compiled to use software floating-point, there is no floating-point instruction set available, and so the ARM libraries have to provide a set of procedure calls to do floating-point arithmetic. These are the software floating-point library, fplib.

These routines have names like _dadd (add two doubles) and _fdiv (divide two floats). The complete list is given in:

User programs can call these routines directly. Even in environments with a coprocessor, the routines are provided, though they are typically only a few instructions long (as all they do is to execute the appropriate coprocessor instruction).

All the fplib routines are called using a software floating-point variant of the calling standard. This means that floating-point arguments are passed and returned in integer registers. In the rest of the program, if the program is compiled for a coprocessor, floating-point data is passed in its floating-point registers.

So, for example, _dadd takes a double in registers r0 and r1, and another double in registers r2 and r3, and returns the sum in r0 and r1.


For a double in registers r0 and r1, the register that holds the high 32 bits of the double depends on whether your program is little-endian or big-endian.

C programs are not required to handle the register allocation.

All the fplib routines are declared in the header file rt_fp.h. You can include this file if you want to call an fplib routine directly.

A complete list of the fplib routines is provided on the following pages.

Copyright © 1999-2001 ARM Limited. All rights reserved.ARM DUI 0067D