top | item 43815116

Show HN: I486SX_soft_FPU – Software FPU Emulator for NetBSD 10 on 486SX

117 points| mezantrop | 10 months ago |github.com

First Release is Here!

I'm excited to announce the first release of i486SX_soft_FPU — a software FPU emulator for the classic Intel 486SX CPU, running on NetBSD 10!

This project brings floating-point support back to life for 486SX machines, even though modern NetBSD versions no longer natively support processors without a hardware FPU. If you're into retrocomputing, operating system hacking, or just love old-school hardware, check it out!

Project page: https://github.com/mezantrop/i486SX_soft_FPU Contributions, feedback, and testing are all very welcome!

Let's keep these vintage machines alive!

#retrocomputing #NetBSD #486SX #opensource

42 comments

order

accrual|10 months ago

This is super cool and I'm very glad to see such work! Does NetBSD natively support the 486DX CPUs which still have the FPU enabled?

I know OpenBSD dropped support for i486 in 6.8, making 6.7 the last that runs natively on them (FPU or not). The support was lost when moving to LLVM 9 and enabling `-march=i586 on i386`. However, old Socket 3 boards can still run the latest version of OpenBSD if one drops a Pentium Overdrive in. :)

dcassett|10 months ago

> Does NetBSD natively support the 486DX CPUs which still have the FPU enabled?

According to [1] they do

"Any i486 or better CPU should work - genuine Intel or a compatible such as Cyrix, AMD, or NexGen."

[1] https://wiki.netbsd.org/ports/i386/

jabl|10 months ago

Just a few days ago patches were posted proposing to drop Linux kernel support for x86 cpus lacking a FPU: https://lore.kernel.org/lkml/20250425084216.3913608-1-mingo@...

ahartmetz|10 months ago

From an outside POV, Linux supports quite unreasonably old hardware, so it's always weird and surprising when someone decides that "now it's TOO unreasonable to keep supporting it".

remlov|10 months ago

Good thing this has nothing to do with NetBSD.

userbinator|10 months ago

Not only the 486SX but a lot of alternative x86 SoCs aimed at embedded systems have no FPU, including the original Vortex86.

natas|10 months ago

I wonder if this means we will soon be able to run Netbsd-10.1 (and above) on MiSTer with ao486 core.

rzzzt|10 months ago

That .jpg in the readme file loaded from right to left. What is this sorcery?

quotemstr|10 months ago

    Z$ identify -verbose weird-jpeg.jpg
    Image:
      Filename: weird-jpeg.jpg
      ...
      Orientation: RightTop
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
      ...
      Properties:
        ...
        unknown: iPhone 12 Pro

adzm|10 months ago

Pretty sure it's orientation in the jpeg itself

hsnewman|10 months ago

I tried it under the Misterfpga ao486 core and it failed, not finding a partition to boot from. :(

karlgkk|10 months ago

So you just consoomed something. Thanks for the contribution

_mlbt|10 months ago

These used to be very common before Pentium processors. Many (most?) compiler tool chains included a software FPU emulator.

Very cool project!

rasz|10 months ago

Duke Nukem 3D is compiled with FPU emulation. Game engine is 99.9% fixed point math, only requires FPU for rarely used slopes (setupslopevlin_ and slopevlin_).

It just so happens first room when starting the game - rooftop - has sloped roof vents and later walls with sloped edge. Even on fast FPUless 90MHz NexGen Nx586 (AMD K6 father) FPS drops down to 10-14fps on that roof https://www.youtube.com/watch?v=41O2bNG2qKA&t=234s while staying above 30 when facing away from slopes.

actionfromafar|10 months ago

I think GCC didn't have the emulating library, but the operating system had. (Such as Debian.) So you could compile and link your programs against a soft-float library. ( Something like this https://github.com/ant6n/ieeelib )

What this NetBSD project does is not exactly like that though, it lets programs use regular 487 float instructions, which are trapped by the kernel, which steps in and emulates what the hardware float instruction would have done.

It worked very well for regular program, because most programs would not use float instructions to any significant degree.

If you however were going to use floats a lot for long calculations, a soft-float library would be much faster.

theragra|10 months ago

I recently encountered this when developing for atmel attiny13a, that has 1KB memory for code. I found that my code somehow cannot fit. Then found that just one line takes around 100 bytes. Insane!

After some experiments, I remembered university course and was able to understand what is going on.

When using float types or operations, fpu emulation is used, which takes huge amount of memory for anything.

I think atmel is using gcc, but not sure if you emulation is part of gcc or atmel libraries.

Turboblack|10 months ago

finally something really useful, I wish you creative success, you are doing the right thing

bezko|10 months ago

What are some examples of an OS needing to do floating point numbers calculations?

PrivacyAI|10 months ago

This is super cool!

evmar|10 months ago

I noticed math_emulate.c comes from Linux (it even has a " * (C) 1991 Linus Torvalds" bit on it). I was wondering what the license on that code is. It looks like Linux adopted GPL in 1992 so maybe this copy predates that, but it was under some other non-BSD license before that.

einr|10 months ago

The full license for Linux prior to 0.12 was:

  This kernel is (C) 1991 Linus Torvalds, but all or part of it may be
  redistributed provided you do the following:

  - Full source must be available (and free), if not with the
    distribution then at least on asking for it.

  - Copyright notices must be intact. (In fact, if you distribute
    only parts of it you may have to add copyrights, as there aren't
    (C)'s in all files.) Small partial excerpts may be copied
    without bothering with copyrights.

  - You may not distibute this for a fee, not even "handling"
    costs.
This is clearly written by someone who has no business writing software licenses ;) but does not appear to be incompatible with the BSD license and in fact, the code in question originates from 386BSD (https://github.com/386bsd/386bsd/blob/2.0/usr/src/kernel/mat...) and made it from there into the NetBSD mainline.

esafak|10 months ago

[deleted]

LukeShu|10 months ago

It's not emulating a crippled chip, it runs on the i486SX (which has no FPU, by artificial limitation or not), and emulates an x87 FPU.