From Righto · · 2m
Inside Intel 8087 Floating-Point Microcode
How Intel's 8087 chip handles floating-point addition and subtraction through microcode.
In brief
How Intel's 8087 chip handles floating-point addition and subtraction through microcode. The 8087 chip uses specialized microcode to perform floating-point addition and subtraction with special cases for infinities and zeros. Originally reported by Righto.
Intel 8087 Chip Introduction

In 1980, Intel introduced the 8087, a chip that made floating-point operations much faster in IBM PC and other systems.
8087 Microcode Focus

The article examines the 8087's microcode and circuitry for floating-point addition and subtraction, including special cases for infinities and other values.
8087 Data Format

The 8087 stores numbers in an 80-bit format called temporary real with a sign bit, 15-bit exponent, and 64-bit significand.
Floating-Point Basics
Floating-point numbers use a sign, significand, and exponent to represent fractional values over an enormous range.
Addition Process
Before adding, the binary points must be aligned by shifting values to match exponents, then the significands are added.
Subtraction Process
Subtraction requires aligning binary points, subtracting significands, and normalizing the result with potential sign changes.
Microcode Implementation

The 8087 implements addition and subtraction through microcode that handles zero cases, exponent comparisons, and normalization.
Special Cases Handling
The 8087 handles special cases including infinities, zeros, Not-a-Number, and denormals with specific microcode paths.
Leading Zero Circuitry
The 8087 uses a two-step process to count leading zeros for shifting values during subtraction and addition.
Exponent Adjustment
The 8087 tracks exponent adjustments through a two-bit register and temporary registers to handle overflow and underflow.
Special Value Handling
The 8087 has specific paths for handling positive and negative zeros, infinities, and Not-a-Number with different rounding rules.
Microcode Complexity
The 8087's microcode includes 18 conditional branches to handle special cases and ensure correct floating-point results.
8087 Legacy
The 8087 led to the IEEE-754 floating-point standard used in modern computing despite some features being dropped from the standard.
Author Background
The author reverse-engineered the 8087 microcode with the Opcode Collective, especially Smartest Blob and Gloriouscow.
Further Resources
The 8087 repository on GitHub provides more details on the microcode and implementation.
The one thing
The 8087 chip uses specialized microcode to perform floating-point addition and subtraction with special cases for infinities and zeros.


