Assembly Language Floating Point and Floating Point Unit
Motivation
To look at floating point data types and floating point instructions in Assembly Language.
Introduction
When working with floating point, we have three different floating point data types: float, double, and extended. In Assembly Language,
we have a specialized processing unit called the FPU or Floating Point Unit. We also have several types of floating point registers
that we can use. These registers are the fp_registers, which are stack based, and we also have the xmm_registers to use for floating point
operations. The FPU has its own set of floating_point_instructions to work with floating point data. List of all Intel 80x86 instructions
can be found at
[ instruction_tables.pdf ]
- float::= IEEE 754 floating point using 32 bits, top bit for sign, 8 bits for the exponent, and 23 bits for the mantissa, with the leading 1 bit
in the mantissa not included as it is an implicit 1 bit that will "always" be there. (This is not the case for 80 bit!!!) For a refresher
on IEEE 754, see
number.systems.html#IEEE Floating Point Formats
do note that Agner Fog has the tables in the document ordered by Integer Instructions, Arithmetic Instructions, Logic Instructions, etc.
- double::= IEEE 754 floating point using 64 bits, top bit for sign, 11 bits for the exponent, and 52 bits for the mantissa, with the leading 1 bit
in the mantissa not included as it is an implicit 1 bit that will "always" be there. (This is not the case for 80 bit!!!) For a refresher
on IEEE 754, see
number.systems.html#IEEE Floating Point Formats
- extended::= IEEE 754 floating point using 80 bits, top bit for sign, 15 bits for the exponent, and 64 bits for the mantissa, with the leading 1 bit
in the mantissa included as an implicit 1 bit. For a refresher on IEEE 754, see
number.systems.html#IEEE Floating Point Formats
- FPU::= Floating Point Unit, found inside the CPU and its primary task is to handle floating point data storage in fp_registers and the execution
of floating_point_instructions. On older processors such as the Intel 8086, 286, 386, and 486, this was called the Math coprocessor, or the 80x87
chip, depending on which class of Intel processor it was running with in conjunction.
- fp_registers::= 80 bit floating point registers, named st(0), st(1), ..., st(7), stack based with the top stack value in the st(0) register. Each time
a new floating point value is placed on the top of the stack, the values already on the stack will be pushed down one stack level. I.e., a
value of 1.25 in st(0) will be pushed down to st(1) if we add a value of 2.75 into st(0).
- xmm_registers::= 128 bit registers that can be used for floating point and for packed integers. These registers are named xmm0, xmm1, ..., xmm15
and are not stack based like the fp_registers.
- floating_point_instructions::= Specialized instructions for working with floating point data values and the stack based floating point
registers. Note, most instructions on the 80x86 that start with the letter f are designated for working with floating point.
. . . . . . . . . ( end of section Assembly Language Floating Point and Floating Point Unit) <<Contents | Index>>