4 comments

  • WalterBright 3 hours ago

    I always thought the 8087 was way cool, but it never really caught on. Early versions of Win32 did not save the 8087 registers on a context switch. I called up some people at Microsoft to please not destroy the 8087, and they relented and preserved the registers.

    I've always been proud to support the 8087 with my compilers, and am baffled why the numerics people ignore it.

    • downut 25 minutes ago

      "numerics people ignored it"

      I dunno Walter but as the first(?) IEEE754 implementation in a PC system it seemed like a pretty damn big deal to us people working in numerical algorithms. It was a big enough deal to me at the time (I was in graduate school) that I've kept my 8087 chip all my life and have it before me now. I see the old boy has lost a pin during the last move, dammit.

      Chip has "3716150AA MALAY BEV 22" embossed on the pin side. Search gets me nothing.

      • jcranmer 1 hour ago

        I mean, the 8087 was the primary influence on IEEE 754, and hence all of modern floating-point, so in that sense, the numerics people don't ignore it.

        The main problem with the x87 floating-point unit is that it only properly works on a weird 80-bit floating-point type that doesn't have the properties you expect of regular IEEE 754 floating-point types, thanks to the explicit integer bit. The design makes it hard to properly emulate the more common 32-bit and 64-bit single and double-precision floating-point arithmetic bit-equivalently, and this is compounded by many compilers' decision to spill floating-point registers incorrectly (they're spilled as 32-bit or 64-bit, not 80-bit), which makes the numerical results of your program effectively random. Also, the size of the 80-bit types isn't really conducive to vectorization, so the floating-point unit gets left behind as SIMD programming starts to become more important.

        So what happens is that the x87 is essentially the last of the pre-IEEE 754 floating-point systems that's still hanging around. A lot of the features that would make it interesting in an environment where every vendor has a different floating-point system are now just vestigial weirdness in a world where everybody is following the same floating-point system, and not worth supporting.

        • downut 31 minutes ago

          The 8087 came out when the premier numerics processors worldwide were the various Cray/CRI products, and if you know this much about the 8087's extended register format then it's likely you already know about Seymour's opinion expressed in silicon about the handling of the LSBs. As a freshly minted computational mathematician I was worried about the Cray systems accuracy on long running computations but after 5 years right on the front lines of the 1-4 highest throughput systems worldwide, with, ISTR, zero practical effect on any computation that ever mattered. Huh turns out Seymour was smarter than me. Should've picked up a shovel.

          As far as delivered accuracy of the 8087, performing the operations at 80 bits, rather than 64 it was better than non-extended formats. Anyway you can read all about it here:

          https://en.wikipedia.org/wiki/Extended_precision#x86_extende...

          Kahan endorsed is all I needed to know.

          I can't remember the details from back then but the initial Sun java implementation did something weird with this.

          • rofluto 5 minutes ago

            Sun wanted the jvm to "replicate exactly" between machines so they chopped off the precision to 64 or 32 which infuriated kahan

          • WalterBright 33 minutes ago

            > this is compounded by many compilers' decision to spill floating-point registers incorrectly (they're spilled as 32-bit or 64-bit, not 80-bit)

            My compilers behaved properly.

          • WalterBright 1 hour ago

            That was win64, not win32. My mistake.

          • dsign 3 hours ago

            Kind of shocking that a 1980 chip could do 80 bits floating points. It makes me a little mad at all of those microcontrollers from this year, 46 years later that ship without floating point support or, at best, 32 bits, but they do come with a "secure island" and a radio capable to ring ET.

            • jart 1 hour ago

              Yeah even NASA doesn't need that many bits. Ken said it himself: https://news.ycombinator.com/item?id=40971913

              • shakna 2 hours ago

                Espressif did finally added back an FPU to the ESP32-S3. (The original ESP32 also has one).

                They tried, with the H- and P- lines to effectively make it a paid extra over the regular productions. At least they accepted when the market disagreed.

                • russdill 2 hours ago

                  But they can, it's just not accelerated by hardware built specifically for the task

                • kens 5 hours ago

                  Author here with another 8087 article. What part of the 8087 should I look at next?

                  • jakzurr 4 hours ago

                    righto.com has been great reading. None of my friends wanted to pay for an 8087, but I can still remember getting out of school (for 2nd time) and saving up for the 486DX after 3 others got them. After that, well, it's been quite a ride.

                    • n923263 5 hours ago

                      Minor erratum: "1.1 (binary) × 2^8 is 304" should be 384.

                      • kens 5 hours ago

                        Thanks! I guess I didn't have my glasses on when I read that number :-)

                      • russdill 2 hours ago

                        There's a ton of coordination lately on P6 microcode. Would love to see what twists and turns there are supporting the older isa on newer architectures

                        • chj 2 hours ago

                          I am curious about the transcendental instructions, how are they implemented, and used, and if actually used

                        • bonzini 4 hours ago

                          Have you already covered how the decoding of instructions is shared with the 8086?

                          • kens 4 hours ago

                            I describe the 8087 instruction decoding here: https://www.righto.com/2026/02/8087-instruction-decoding.htm...

                            • bonzini 1 hour ago

                              How do FSTSW AX and similar instructions write to AX?

                              • rep_lodsb 57 minutes ago

                                That instruction was only introduced with the 80287. Unlike the 8086/8088, the 286 CPU was aware of different classes of x87 opcodes: it had to distinguish between ones that read or write memory, and some special control instructions as well.

                                So FSTSW AX was handled by the CPU microcode, which would read the status word from a reserved I/O port and put it into AX.

                                The 386 was even more tightly integrated, with some of the FPU state duplicated inside the CPU, so that it could store it to memory in different formats depending on whether it was currently in 16- or 32-bit mode.

                        • kar1181 2 hours ago

                          Gosh thank goodness for Ken, a beacon of light in a sea of slop. For all these years, and countless hours of posts and videos, thank you.