Do any modern machines not have an FPU?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Do any modern machines not have an FPU?

Post by nexos »

Hello,
I am working on CPU identification code in my OS, but as I was reading through the CPUID spec, I saw that there is a bit for 80387 compatibility. Does this mean that there a chance that modern CPUs may not support the 80387 ISA? Or is this flag outdated?
Thanks,
nexos
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Do any modern machines not have an FPU?

Post by Octocontrabass »

Modern embedded CPUs might not support it. For example, this one.

Otherwise, you don't have to worry. 387-class FPUs have been standard since the Pentium.
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: Do any modern machines not have an FPU?

Post by nexos »

Ok that is what I figured. Thanks!
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
sj95126
Member
Member
Posts: 151
Joined: Tue Aug 11, 2020 12:14 pm

Re: Do any modern machines not have an FPU?

Post by sj95126 »

Given that almost nothing ever disappears from the x86 architecture, we can reasonably assume that the 80387 flag will always be there, especially after what happened last time.

For those who aren't familiar with how Intel botched this in the late 1980s, here's the story. Until the 80486 came out, a coprocessor was an optional separate component. For the 8086, it was the 8087 FPU, for the 80286 it was the 80287, etc. etc. Motherboards usually had an empty socket where the end user could add in the chip. If there was an FPU, there was a mechanism for software to detect it (I forget what it was, whether it was attempting an instruction like FINIT and catching the exception, or something else). And then, of course, if there was no FPU, a program might load a software FP library instead.

Now, as you've probably seen, before the CPUID instruction was introduced in the Pentium, and a few of the late model 80486 chips, there was a tedious sequence of instructions software could use to detect what type of CPU you were on, based on certain behaviors. You detect an 8086 vs. a 80186 by pushing SP and figuring out whether it decremented SP before or after the push, and then run further tests to detect a 80186 vs a 80286 vs 80386 and so forth. (As far as I know, this detection code is still in the Linux kernel)

Then Intel came out with the 80486 with an integrated FPU, and everyone said "Hooray! We don't have to test for the FPU any more. If we detect an 80486, then we have an FPU too." This worked great ... until Intel introduced the slimmed down 486SX with no FPU (I can't remember if there wasn't even one in the silicon, or if it was disabled). I remember when this happened (yes, I'm kinda old) and a whole lot of people were ticked off that Lotus 123 was crashing on their brand new computers because the developers had basically taken a shortcut in the feature detection. I don't think Intel warned anyone, but to be fair, you can't really blame them for not revealing their product roadmap either.

Anyway, yes, you aren't likely to encounter something without an FPU these days, but it's still probably responsible programming practice to detect a feature before using it.
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Do any modern machines not have an FPU?

Post by Octocontrabass »

sj95126 wrote:For the 8086, it was the 8087 FPU, for the 80286 it was the 80287, etc. etc.
For the 386, it was the 387, except it took Intel a while to finish the 387 so they made the 386 also work with the 287. (Then they later went back and made a 387 that worked with the 186 and 286.) FPU history is fun!
sj95126 wrote:If there was an FPU, there was a mechanism for software to detect it (I forget what it was, whether it was attempting an instruction like FINIT and catching the exception, or something else).
Catching exceptions would be too easy. You had to tell the FPU to write its control and status registers into memory, then read that memory and see if the values looked like something a FPU would write. You also had to be careful which instructions you used, since some of them could cause the CPU to hang if no FPU was installed.
sj95126 wrote:(I can't remember if there wasn't even one in the silicon, or if it was disabled).
It's both. Earlier ones had it disabled, later ones removed it. It's not clear exactly how it was disabled, since disabling the FPU also required changing the CPU signature.
sj95126
Member
Member
Posts: 151
Joined: Tue Aug 11, 2020 12:14 pm

Re: Do any modern machines not have an FPU?

Post by sj95126 »

Octocontrabass wrote:It's not clear exactly how it was disabled, since disabling the FPU also required changing the CPU signature.
I seem to remember something about the FPU-disabled CPUs having a notched corner where one of the PGA pins was missing. It's possible I'm thinking of something else, though.
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Do any modern machines not have an FPU?

Post by Octocontrabass »

The 487SX had an extra pin, not connected to anything, that would prevent it from being installed the wrong way or in the wrong socket. Maybe that's what you're thinking of?

I don't think anyone has ever found a pin that would change the signature depending on how it's connected.
Post Reply