# Using floating point hardware to process long addresses.

Norman Hardy norm@netcom.com
Fri, 4 Sep 1998 01:02:08 -0400

```The basic idea is to abstract the representation of the number. By this I
mean that the following properties are verified without reference to kernel
code that uses floating code and kernel correctness of floating values
depends only on the following facts. Here is about all that you need to

Begin Axioms:

When operands and result are within the inclusive integer range [-2^64 :
2^64] then addition, subtraction and multiplication are exact.

Multiplication by a power of two is exact even when that operand is not an
integer.

The instructions (or routines) to convert between integer and floating
point are exact, except, of course, when the fixed value is inexpressible.
I presume that you can get the style of rounding that you need, probably
rounding down. ANSI expressions such as
floor(x) are probably correct but even faster methods may be available by
using expressions such as (x+c)-c where c is some magic constant near
3*2^64.

The floating values in question require 80 bits when stored in RAM. (It may
not be necessary to store them in RAM.) This is unique to the x86
architecture.

Floating comparison (such as provided by the C operators <) is exact for
our purposes.

End Axioms.

When extracting a field from an address you always want to verify that it
is the most significant bits in the value. An expression such as
floor(addr*pm40) extracts the bits to the left of the rightmost 40 bits.
(pm40 is the constant 2^-40).

Notice that there is no need to divide!!

For reasons that are not entirely clear various chip manufacturers have
made floating operations unreasonably fast. Use them. The 370 kernel used
floating point to deal with the 48 bit addresses there.

Norman Hardy  <http://www.mediacity.com/~norm>

```