6 ms·
Microcode in Intel's 8087 floating-point chip: the scale instruction
- kens 4d agoAuthor here for your 8087 questions...
- deleted 4d ago[deleted]
- bonzini 4d agoThat's a really vertical microcode. It looks more like a specialized assembly than microcode. I guess it makes sense, since the algorithms are so complex and executing one microinstruction per cycle (is that correct?) already provides almost an order of magnitude performance improvement.
- kens 4d agoYes, it's one microinstruction per cycle, except there is a 1-cycle delay for branches, adds, and shifts. And some micro-instructions loop, so they can take a bunch of cycles.
- pechay 4d agoGreat work! I love to read your articles. I'm curious to know - you say Intel's 8087 emulation code was a bit of a lump at 16KB, do you know if it emulated the 8087 microcode state machine or did it use a different strategy?
- kens 4d agoI think the emulation code was a rewrite in 8086 assembly language. An 8087 microcode emulator would be slow and difficult. One of the Opcode Collective people is looking at the emulator now, so there may be more details later. Intel claimed that the emulator completely and exactly duplicated the 8087 functionality, so it would be interesting to see if it is 100% accurate or if they missed any corner cases.
- agumonkey 4d agono questions, just thanks
- cogman10 4d agox87 is such a weird architecture. It was designed the same way you'd design a chip for a scientific calculator. Heck, It's almost a perfect fit for an HP RPN calculator. But for a compiler to target, it's just so painful. It's so different from almost all other ways CPUs work. There's a reason both CPU and compilers prefer to avoid x87 when possible and use regular SIMD (SSE/AVX) instead. Also, the arbitrary "Oh, and the registers are 80 bits wide" is also just one of those weird "Where did that number come from?".
- matja 4d ago> Also, the arbitrary "Oh, and the registers are 80 bits wide" is also just one of those weird "Where did that number come from?". One of the features that was advertised (mentioned in the iAPX 86, 88, 186 Microprocessors Part II book (July 1984)) was the ability to do exact arithmetic on integers up to 2^64, which is possible due to the 64-bit mantissa used in the 80-bit format.
- mortja 4d agoSo in a sense the 8087 was the first 64 bit CPU?
- matja 4d agoI wouldn't say so, because it was a co-processor: e.g., it depended on the 8086 to even generate addresses for memory operations. I think the IBM 7030 Stretch CPU (from 1964) would be a likely contender for being one of the first 64-bit CPUs.
- phire 3d agoAlso, even if ignored the fact that it was a co-processor, we don't generally count the width of the floating point and vector registers. Otherwise most modern CPUs would be labeled as either 256-bit or 512-bit. These days we generally label CPUs based on the width of the general purpose registers (though, it gets messy with things like the 68000). I personally suspect we won't ever see GPRs wider than 64 bits.
- garganzol 4d ago100x speed improvement of math operations by 8087 is not an overestimation. The difference for apps relying on math was crazy back then. I experienced this first-hand on my 80286 machine, where it was 3-second vs 300-second calculation results. One neat feature of 8087 instruction set is that it can be interspersed with x86 instructions in the code stream, giving you a simultaneous access to two processor chips working in parallel. This combo forms a real asymmetrical multi-processor system with certain opportunities for hardware-assisted code parallelization. If a thoughtful instruction scheduling is used, floating operations executed by 8087 work in parallel with the usual integer x86 code.
- mgaunard 4d agoAny modern processor has different execution ports specialized in different things and replicated a different number of times, and all of them can execute instructions in parallel. It schedules to these transparently for you, that's known as superscalar execution. To maximize occupation, out-of-order execution and simultaneous multithreading are used.
- Sharlin 4d agoSure, but this was five (or six?) generations before actual superscalar x86 processors.
- vlovich123 4d agoThree - after 8086 you had 80286, 80386, 80486 and then Pentium (superscalar).
- dpq 4d ago80186 is often forgotten to have existed because it didn't see much success in the market / because IBM skipped it and went with 80286 for the AT, but it did exist.
- 4d ago
- finn888 4d agoThe jump from a simple scale instruction to 140 micro-instructions makes the special-case machinery much more concrete.