Keil Logo

Technical Support

On-Line Manuals

Libraries and Floating Point Support Guide

Preface The ARM C and C++ Libraries The ARM C Micro-library Floating-point Support About floating-point support The software floating-point library, fplib Calling fplib routines fplib arithmetic on numbers in a particular format fplib conversions between floats, long longs, doub fplib comparisons between floats and doubles fplib C99 functions Controlling the ARM floating-point environment Floating-point functions for compatibility with Mi C99-compatible functions for controlling the ARM f C99 rounding mode and floating-point exception mac Exception flag handling Functions for handling rounding modes Functions for saving and restoring the whole float Functions for temporarily disabling exceptions ARM floating-point compiler extensions to the C99 Writing a custom exception trap handler Example of a custom exception handler Exception trap handling by signals mathlib double and single-precision floating-point IEEE 754 arithmetic Basic data types for IEEE 754 arithmetic Single precision data type for IEEE 754 arithmetic Double precision data type for IEEE 754 arithmetic Sample single precision floating-point values for Sample double precision floating-point values for IEEE 754 arithmetic and rounding Exceptions arising from IEEE 754 floating-point ar Exception types recognized by the ARM floating-poi Using the Vector Floating-Point (VFP) support libr The C and C++ Library Functions reference Floating-point Support Functions Reference

Calling fplib routines

3.2.1 Calling fplib routines

Floating-point routines have names like __aeabi_dadd (add two doubles) and __aeabi_fdiv (divide two floats). User programs can call these routines directly.

Even in environments with a coprocessor, the routines are provided. They are typically only a few instructions long because all they do is 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. By contrast, if the program is compiled for a coprocessor, floating-point data is passed in its floating-point registers.
So, for example, __aeabi_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.
Software floating-point library routines are declared in one of two header files:
  • A small number of fplib routines that implement C99 functionality are declared in the standard header file math.h.
  • All other 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.
To call a function from assembler, the software floating-point function is named fn. For example, to call the nextafter() function, implement the following code:
IMPORT nextafter
BL nextafter
Non-ConfidentialPDF file icon PDF versionARM DUI0378H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.