14 comments

  • johngossman11 hours ago
    Sometime in the 80s, I implemented the core of the Mandelbrot Set calculation using assembly on an 8087. As the article mentions, the compilers did math very inefficiently on this stack architecture. For example, if you multiplied two numbers together and then added a third, they would push the first two numbers, multiply, pop the result, push the result back onto the stack (perhaps clearing the stack? after 40 years I don&#x27;t remember), push the third number, add, pop the result. For the Mandelbrot loop this was even worse, as it never kept the results of the loop. My assembly kept all the intermediate results on the stack for a 100x speed up.<p>Running this code, the 8087 emitted a high-pitched whine. I could tell when my code was broken and it had gone into an infinite loop by the sound. Which was convenient because, of course, there was no debugger.<p>Thanks for bringing back this memory.
    • anyfoo7 hours ago
      Ah, lots of supposedly solid state computer stuff, including CPUs, did that. I, too, used it for debugging. This wasn&#x27;t very conscious on my part, but if some whine became unusual and constant, it was often a sign of something hanging.<p>As I got older, not only did computers stop doing that, my hearing also got worse (entirely normal for my age, but still), so that&#x27;s mostly a thing of the past.
      • userbinator6 hours ago
        The sound usually comes from inductors and capacitors in the power supply circuitry, not the ICs themselves as they draw pulses of power in patterns at audible frequencies. Modern CPUs and GPUs will still whine audibly if given a suitable load; the amount of current they consume is amazingly high, dozens to hundreds of amps, and also changing extremely quickly.
      • WalterBright2 hours ago
        I used to hear the 16KHz whistle of CRT monitors. Of course, there is no whistle with LED monitors, but I stopped hearing the CRT whistle before they went obsolete. It was my first sign my hearing was declining.<p>I thought I was protecting my ears from loud noises like rock concerts and gunshots. But I didn&#x27;t know that driving with the window down damages the hearing. I crossed the country many times with the window down. I&#x27;m pretty sure that was the cause as my left ear is much worse off than my right.<p>I don&#x27;t need a hearing aid yet, but I&#x27;m pretty careful in wearing ear plugs whenever there are loud noises.
        • anyfoo2 hours ago
          16 kHz is very high on the spectrum. Just the normal age-related decline of hearing makes that inaudible pretty quickly, you don’t need to drive with the window down for that.
          • WalterBright1 hour ago
            You&#x27;re right, but it was coincident with my realizing I had trouble hearing my watch tick with my left ear.
      • hnuser1234567 hours ago
        I had a Radeon 5850 that did it. I ran someone&#x27;s simple test unity project with vsync disabled, was getting around 3000 fps, and heard a tone that was probably 3000hz. Supposedly the 5090 FE&#x27;s are pretty bad too.
    • userbinator6 hours ago
      The compilers available at the time that the 8087 was commonplace were overall horrible and easily beaten anyway.<p>On the other hand, skilled humans can do very very well with the x87; this <i>256-byte</i> demo makes use of it excellently: <a href="https:&#x2F;&#x2F;www.pouet.net&#x2F;prod.php?which=53816" rel="nofollow">https:&#x2F;&#x2F;www.pouet.net&#x2F;prod.php?which=53816</a>
      • WalterBright2 hours ago
        Yah, I never did a very good job with x87 code generation. I&#x27;m a bit embarrassed by that.
    • anthk8 hours ago
      - You can do the Mandelbrot set with integers. In Forth it&#x27;s 6 lines.<p>- Coincidentally, Forth promotes a fixed point philosophy.<p>- Forth people defined the IEEE754 standard on floating point, because they knew how to do that <i>well</i> in software.
      • jcranmer7 hours ago
        &gt; - Forth people defined the IEEE754 standard on floating point, because they knew how to do that well in software.<p>IEEE 754 was principally developed by Kahan (in collaboration with his grad student, Coonen, and a visiting professor, Stone, whence the name KCS draft), none of whom were involved with Forth in any way that I am aware. And the history is pretty clear that the greatest influence on IEEE 754 before its release was Kahan&#x27;s work with Intel developing the 8087.
        • WalterBright2 hours ago
          I&#x27;m a big fan of Kahan&#x27;s work. I am just sad that the NaN remains terribly misunderstood.<p>The signalling NaN, however, turned out to be quite useless and I abandoned it.<p>I think the Zortech C++ compiler was the first one to fully support NaN with the Standard library.
  • mbf15 hours ago
    There were a couple interesting points about the market for 8087 chips -- Intel designed the motherboard for the IBM PC, and they included an 8086 slot and a slot for either an 8087 or 8089. IBM didn&#x27;t populate the slot for the coprocessor chip as it would compete with their mainframes, but Intel went around marketing the chips to research labs. One of them ended up with Stephen Fried who founded Microway in 1981 to create software for the 8087 and sell the chips, and the company is still in business after 44 years of chasing high performance computing. That&#x27;s how I first got started with computing - a Microway Number Smasher (TM) card in an IBM PC.<p>The 80287 (AKA 287) and 80387 (AKA 387) floating point microprocessors started to pick up some competition from Weitek 1167 and 4167 chips and Inmos Transputer chips, so Intel integrated the FPU into the CPU with the 80486 processor (I question whether this was a monopoly move on Intel&#x27;s part). This was also the first time that Intel made multiple versions of a CPU - there was a 486DX and a 486SX (colloquially referred to as the &quot;sucks&quot; model at the time) which disabled the FPU.<p>The 486 was also interesting because it was the first Intel x86 series chip to be able to operate at a multiple of the base frequency with the release of the DX2, DX3, and DX4 variants which allowed for different clock rates of 50MHz, 66MHz, 75MHz, and 100MHz based on the 25MHz and 33MHz base clock rates. I had a DX2-66MHz for a while and a DX4-100. The magic of these higher clock rates came from the introduction of the cache memory. The 486 was the first Intel CPU to utilize a cache.<p>Even though Intel had superseded the 8087&#x2F;287&#x2F;387 floating point coprocessor by including the latest version in the 80486, they introduced the 80860 (AKA i860) which was a VLIW RISC-based 64-bit FPU that was significantly faster, and also was the first microprocessor to exceed 1 million transistors.<p>The history of the FPU dedicated for special purpose applications is that it eventually became superseded by the GPU. Some of the first powerful GPUs from companies like Silicon Graphics utilized a number of i860 chips on a card in a very similar structure to more modern GPUs. You can think of each of the 12x i860 chips on an SGI Onyx &#x2F; RealityEngine2 like a Streaming Multiprocessor node in an NVIDIA GPU.<p>Obviously, modern computers run at significantly faster clock speeds with significantly more cache and many kinds of cache, but it&#x27;s good to look at the history of where these devices started to appreciate where we are now.
    • WalterBright2 hours ago
      &gt; I question whether this was a monopoly move on Intel&#x27;s part<p>Well, I was happy about that because I no longer had to deal with switches to generated x87 code or emulate it.
    • inejge2 hours ago
      &gt; The 80287 (AKA 287) and 80387 (AKA 387) floating point microprocessors started to pick up some competition from Weitek 1167 and 4167 chips and Inmos Transputer chips, so Intel integrated the FPU into the CPU with the 80486 processor (I question whether this was a monopoly move on Intel&#x27;s part).<p>I don&#x27;t think it was, transistor density became sufficient to integrate such a hefty chunk of circuitry on-die. Remember that earlier CPUs had even things like MMUs as separate chips, like Motorola 68851.
  • userbinator1 hour ago
    <i>I don&#x27;t know what the GRX field is.</i><p>The field of the instruction that selects the stack offset.
  • kens13 hours ago
    Author here for your 8087 questions...
    • xenadu0210 hours ago
      If you happen to know... what was the reasoning behind the oddball stack architecture? It feels like Intel must have had this already designed for some other purpose so they tossed it in. I can&#x27;t imagine why anyone would think this arch was a good idea.<p>Then again... they did try to force VLIW and APX on us so Intel has a history of &quot;interesting&quot; ideas about processor design.<p>edit: You addressed it in the article and I guess that&#x27;s probably the reason but for real... what a ridiculous hand-wavy thing to do. Just assume it will be fine? If the anecdotes about Itanium&#x2F;VLIW are true they committed the same sin on that project: some simulations with 50 instructions were the (claimed) basis for that fiasco. Methinks cutting AMD out of the market might have been the real reason but I have no proof for that.
      • kens10 hours ago
        Stack-based architectures have an appeal, especially for mathematics. (Think of the HP calculator.) And the explanation that they didn&#x27;t have enough instruction bits also makes sense. (The co-processor uses 8086 &quot;ESCAPE&quot; instructions, but 5 bits get used up by the ESCAPE itself.) I think that the 8087&#x27;s stack could have been implemented a lot better, but even so, there&#x27;s probably a reason that hardly any other systems use a stack-based architecture. And the introduction of out-of-order execution made stacks even less practical.
        • jcranmer7 hours ago
          To expand on this a little bit more:<p>x86 has a general pattern of encoding operands, the ModR&#x2F;M byte(s), which gives you either two register operands, or a register and a memory operand. Intel also did this trick that uses one of the register operand for extra opcode bits, at the cost of sacrificing one of the operands.<p>There are 8 escape opcodes, and all of them have a ModR&#x2F;M byte trailing it. If you use two-address instructions, that gives you just 8 instructions you can implement... not enough to do anything useful! But if you&#x27;re happy with one-address instructions, you get 64 instructions with a register operand and 64 instructions with a memory operand.<p>A stack itself is pretty easy to compile for, until you have to spill a register because there&#x27;s too many live variables on the stack. Then the spill logic becomes a nightmare. My guess is that the designers were thinking along these lines--organizing the registers in the stack is an efficient way to use the encoding space, and a fairly natural way to write expressions--and didn&#x27;t have the expertise or the communication to realize that the design came with some edge cases that were painfully sharp to deal with.
        • WalterBright2 hours ago
          &gt; there&#x27;s probably a reason that hardly any other systems use a stack-based architecture<p>I don&#x27;t know about other backend guys, but I disliked the stack architecture because it just incompatible with enregistering variables, register allocation by live range analysis, common subexpression elimination, etc.
    • mzs10 hours ago
      insightful footnote, thanks: <a href="https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20190301193516&#x2F;http:&#x2F;&#x2F;www.drdobbs.com&#x2F;architecture-and-design&#x2F;a-conversation-with-william-kahan&#x2F;184410314" rel="nofollow">https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20190301193516&#x2F;http:&#x2F;&#x2F;www.drdobb...</a>
    • ForOldHack12 hours ago
      Make no mistake, this article is of extraordinary historical significance, even the list of constantans being hardwired....
  • tigranbs11 hours ago
    The 2-bit-per-transistor ROM using four transistor sizes is wild. Were there other chips from this era experimenting with semi-analog storage, or was the 8087 unusually aggressive here?
    • kens11 hours ago
      Intel also used the 2-bit-per-transistor ROM in the iAPX 432, their unsuccessful &quot;micro-maninframe&quot; chip.<p>Nowadays, flash uses multiple voltage levels to store four bits per cell (QLC, Quad Level Cell), which is a similar concept.<p>I wrote a whole blog post about the 2-bit-per-transistor technique, back in 2018: <a href="https:&#x2F;&#x2F;www.righto.com&#x2F;2018&#x2F;09&#x2F;two-bits-per-transistor-high-density.html" rel="nofollow">https:&#x2F;&#x2F;www.righto.com&#x2F;2018&#x2F;09&#x2F;two-bits-per-transistor-high-...</a>
  • em3rgent0rdr11 hours ago
    Looking at the complexity and area of hardware floating point, I often wonder why we don&#x27;t see more unified combined integer+floating point units, like done in the R4200 [1], which reused most of the integer datapath while just adding a smaller extra smaller 12-bit datapath for the exponent.<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;R4200" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;R4200</a>
    • bobmcnamara10 hours ago
      The integer pipeline is often needed for address calculation near the same time as the floating point pipeline.<p>The R4200 FPU performance suffered for this reason.
  • garaetjjte8 hours ago
    Story of how Intel-derived proposal was standardized as IEEE754: <a href="https:&#x2F;&#x2F;people.eecs.berkeley.edu&#x2F;~wkahan&#x2F;ieee754status&#x2F;754story.html" rel="nofollow">https:&#x2F;&#x2F;people.eecs.berkeley.edu&#x2F;~wkahan&#x2F;ieee754status&#x2F;754st...</a>
  • hyperman110 hours ago
    I didn&#x27;t expect the microcode to be at the center of the chip. I&#x27;d expect it on the side and only talking to the microcode engine, making more room for data traffic between chip halves. Also, the microcode is huge.
    • kens10 hours ago
      The microcode was so huge that they had to use a semi-analog ROM that held two bits per transistor by using four transistor sizes.<p>As far as the layout, the outputs from the microcode ROM are the control signals that go to all parts of the chip, so it makes sense to give it a central location. There&#x27;s not a lot of communication between the upper half of the chip (the bus interface to the 8086 and memory) and the lower half of the chip (the 80-bit datapath), so it doesn&#x27;t get in the way too much. That said, I&#x27;ve been tracing out the chip and there is a surprising amount of wiring to move signals around. The wiring in the 8087 is optimized to be as dense as possible: things like running some parallel signals in silicon and some in polysilicon because the lines can get squeezed together just a bit more that way.
  • CaliforniaKarl10 hours ago
    I wonder, if C used Reverse-Polish notation for math operations, would compilers have been able to target the 8087 better than they did?
    • ack_complete4 hours ago
      Nah. As others have said, translating infix to RPN is pretty easy to do. The nasty part was keeping values within registers on the stack, especially within loops. The 8087 couldn&#x27;t do binary ops between two arbitrary locations on the stack, one had to be the top of stack. This meant that if you need to add two non-top locations, for example, you had to exchange (FXCH) one of them to the top of the stack first. This meant that optimized x87 code tended to be a mess of FXCH instructions.<p>Complicating this further, doing this in a loop requires that the stack state match between the start and end of the loop. This can be challenging to do with minimal FXCH instructions. I&#x27;ve seen compilers emit 3+ FXCH instructions in a row at the end of a loop to match the stack state, where with some hairy rearrangement it was possible to get it down to 2 or 1.<p>Finally, the performance characteristics of different x87 implementations varied in annoying ways. The Intel Pentium, for instance, required very heavy use of FXCH to keep the add and multiply pipelines busy. Other x87 FPUs at the time, however, were non-pipelined, some taking 4 cycles for an FADD and another 4 cycles for FXCH. This meant that rearranging x87 code for Pentium could _halve_ the speed on other CPUs.
      • rasz3 hours ago
        To the last point I would see it the other way around. Rearranging code for pipelined 0 cycle FXCH Pentium FPU speed up floating point by probably way more than x2 compared to heavily optimized code running on K5&#x2F;K6. Im not even sure if K6&#x2F;-2 ever got 0 cycle FXCH, K6-3 did, but still no FPU pipelining until Athlon.<p>Quake wouldnt happen until Pentium 2 if Intel didnt pipeline FPU.
        • ack_complete3 hours ago
          You&#x27;re not wrong, the performance gain from proper FPU instruction scheduling on a Pentium was immense. But applications written prior to Quake and the Pentium gaining prominence or non-game oriented would have needed more blended code generation. Optimizing for the highest end CPU at the time at the cost of the lowest end CPU wouldn&#x27;t necessarily have been a good idea, unless your lowest CPU was a Pentium. (Which it was for Quake, which was a slideshow on a 486.)<p>K6 did have the advantage of being OOO, which reduced the importance of instruction scheduling a lot, and having good integer performance. It also had some advantage with 3DNow! starting with K6-2, for the limited software that could use it.
    • kens10 hours ago
      My compiler knowledge is limited, but I think that you end up with the same parse tree at a very early level of processing, whether you use Reverse-Polish notation or inline notation. So I don&#x27;t think a language change would make a difference.
    • bonzini8 hours ago
      Converting to RPN is, roughly speaking, the easiest way to generate code for either register or stack architectures.<p>Once you have a parse tree, visiting it in post order (left tree, right tree, operation) produces the RPN.
  • librasteve9 hours ago
    Looks like a log multiply-adder ... maybe a 5 clock cycle? Also, on the microcode ... them FP divide algorithms are pretty intense.<p>Would be cool to hear a real designer compare to the Weitek 1064.
  • lisbbb2 hours ago
    I made my Dad buy me a 387 math coprocessor when I was in college because I was taking math and physics courses but I bet none of the software I used ever even accessed that chip. It was more about the empty socket on the mobo looking out of place.
  • leeter10 hours ago
    I remember failing an interview with the optimization team of a large fruit trademarked computer maker because I couldn&#x27;t explain why the x87 stack was a bad design. TBF they were looking for someone with a masters, not someone just graduating with a BS. But, now I know... honestly, I&#x27;m still not 100% sure what they were looking for in an answer. I assume something about register renaming. memory, and cycle efficiency.
    • kens10 hours ago
      Having given a zillion interviews, I expect that they weren&#x27;t looking for the One True Answer, but were interested in seeing if you discussed plausible reasons in an informed way, as well as seeing what areas you focused on (e.g., do you discuss compiler issues or architecture issues). Saying &quot;I dunno&quot; is bad, especially after hints like &quot;what about ...&quot; and spouting complete nonsense is also bad.<p>(I&#x27;m just commenting on interviews in general, and this is in no way a criticism of your response.)
      • leeter9 hours ago
        I think I said something about the stack efficiency. I was a kid that barely understood out of order execution. Register renaming and the rest was well beyond me. It was also a long time ago, so recollections are fuzzy. But, I do recall is they didn&#x27;t prompt anything. I suspect the only reason I got the interview is I had done some SSE programming (AVX didn&#x27;t exist yet, and to give timing context AltiVec was discussed), and they figured if I was curious enough to do that I might not be garbage.<p>Edit: Jogging my memory I believe they were explicit at the end of the interview they were looking for a Masters candidate. They did say I was on a good path IIRC. It wasn&#x27;t a bad interview, but I was very clearly not what they were looking for.
  • burnt-resistor11 hours ago
    Very cool.<p>It&#x27;s all about that 80-bit&#x2F;82-bit floating point format with the explicit mantissa bit just to be extra different. ;) Not only is it a 1:15:1:63, it&#x27;s (2(tag)):1:15:1:63, whereas binary64 is 1:11:0:52. (sign:exponent [biased]:explicit leading mantissa bit stored?:manitissa remaining)<p>Other pre-P5 ISA idiosyncrasies: Only the 8087 has FDISI&#x2F;FNDISI, FENI&#x2F;FNENI. Only the plain 287 has a functional FSETPM. Most everything else looks like a 387 ISA-wise, more or less until MMX arrived. That&#x27;s all I know.<p>I&#x27;m curious what the CX-83D87 and Weiteks look like.<p>Keep up the good work!<p>PS: Perhaps sometime in the (near) future we might get almost 1:1 silicon &quot;OCR&quot; transcription of die scans to FPGA RTL with bugs and all?
    • mschaef11 hours ago
      &gt; I&#x27;m curious what the CX-83D87 and Weiteks look like.<p>The Weitek&#x27;s were memory mapped. (At least those built for x86 machines.).<p>This essentially increased bandwidth by using the address bus as a source for floating point instructions. Was really a very cool idea, although I don&#x27;t know what the performance realities were when using one.<p><a href="http:&#x2F;&#x2F;www.bitsavers.org&#x2F;components&#x2F;weitek&#x2F;dataSheets&#x2F;WTL-3167_80386_Floating-Point_Coprocessor_Sep88.pdf" rel="nofollow">http:&#x2F;&#x2F;www.bitsavers.org&#x2F;components&#x2F;weitek&#x2F;dataSheets&#x2F;WTL-31...</a>
      • andrewf5 hours ago
        This is nuts, in the best way.<p><i>The operand fields of a WTL 3167 address have been specifically designed so that a WTL 3167 address can be given as either the source or the destination to a REP MOVSD instruction.</i> [<p><i>Single-precision vector arithmetic is accomplished by applying the 80386 block move instruction REP MOVSD to a WTL 3167 address involving arithmetic instead of loading or storing.</i>
      • librasteve9 hours ago
        haha - took me a while to figure out that&#x27;s Mauro Bonomi&#x27;s signature<p>iirc the 3167 was a single clocked, full barrel shift mac pipeline with a bunch (64?) of registers, so the FPU could be driven with a RISC-style opcode on every address bus clock (given the right driver on the CPU) ... the core registers were enough to run inner loops (think LINPACK) very fast with some housekeeping on context switch of course<p>this window sat between full PCB minicomputer FPUs made from TTL and the decoupling of microcomputer internal clocks &amp; cache from address bus rates ...<p>Weitek tried to convert their FPU base into an integrated FPU&#x2F;CPU play during the RISC wars, but lost
  • ForOldHack12 hours ago
    This is cool, but the renormalization and (Programmable and bidirectional) barrel shifter are of much more interest.<p>I had a 10Mhz XT, and ran a 8087-8 at a bit higher clock rate. I used it both for Lotus 1-2-3 and Turbo Pascal-87. It made Turbo Pascal significantly faster.
    • kens11 hours ago
      You&#x27;re in luck, I wrote about the 8087&#x27;s shifter back in 2020 :-) <a href="https:&#x2F;&#x2F;www.righto.com&#x2F;2020&#x2F;05&#x2F;die-analysis-of-8087-math-coprocessors.html" rel="nofollow">https:&#x2F;&#x2F;www.righto.com&#x2F;2020&#x2F;05&#x2F;die-analysis-of-8087-math-cop...</a>