OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:26 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Do any modern machines not have an FPU?
PostPosted: Fri Jun 25, 2021 9:50 am 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
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


Top
 Profile  
 
 Post subject: Re: Do any modern machines not have an FPU?
PostPosted: Fri Jun 25, 2021 10:02 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
 Post subject: Re: Do any modern machines not have an FPU?
PostPosted: Fri Jun 25, 2021 10:54 am 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
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


Top
 Profile  
 
 Post subject: Re: Do any modern machines not have an FPU?
PostPosted: Fri Jun 25, 2021 10:23 pm 
Offline
Member
Member

Joined: Tue Aug 11, 2020 12:14 pm
Posts: 151
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.


Top
 Profile  
 
 Post subject: Re: Do any modern machines not have an FPU?
PostPosted: Sat Jun 26, 2021 12:34 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
 Post subject: Re: Do any modern machines not have an FPU?
PostPosted: Sat Jun 26, 2021 7:36 pm 
Offline
Member
Member

Joined: Tue Aug 11, 2020 12:14 pm
Posts: 151
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.


Top
 Profile  
 
 Post subject: Re: Do any modern machines not have an FPU?
PostPosted: Sun Jun 27, 2021 6:00 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], SemrushBot [Bot] and 66 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group