PitchHut logo
i486SX_soft_FPU
by instant_aquamarine_berte
Restoring FPU emulation for legacy i486SX CPUs on NetBSD.
Pitch

This project revives x87 FPU emulation for i486SX CPUs on NetBSD 10.x, reintroducing the MATH_EMULATE option that supported legacy processors without hardware FPUs. It aims to enhance compatibility and performance in retro-computing, providing essential tools for users and developers involved in maintaining vintage systems.

Description

FPU Emulation Revival for i486SX on NetBSD

This retro-computing project aims to restore support for x87 floating-point unit (FPU) emulation in the NetBSD kernel, specifically targeting legacy 486SX-class processors that lack hardware FPUs. By integrating the original MATH_EMULATE option into NetBSD 10.x and beyond, this initiative reverts and enhances the alterations made in commit dfe83e0, which previously removed FPU emulation support from the kernel.

Project Status

This project is in active development and may exhibit bugs or incomplete features. Users are encouraged to proceed with caution, as the developer is not liable for any issues resulting from its usage.

Known Issues

  • The fyl2x instruction appears to function properly; however, invoking log functions from libc yields incorrect results.
  • Certain operations may have subtle precision discrepancies.

Supported x87 FPU Instructions

Control & Initialization

InstructionStatusDescriptionOpcodeExample
fninit✅ OKInitialize FPU9B DB E3fninit

Load Instructions

InstructionStatusDescriptionOpcodeExample
fld✅ OKLoad floating-point valueD9 /0fld st(1)
fldt✅ OKLoad 80-bit extended precisionDB /5fldt [mem]
filds✅ OKLoad short integerDB /0filds [mem]
fildl✅ OKLoad long integerDB /Afildl [mem]

Store Instructions

InstructionStatusDescriptionOpcodeExample
fstps✅ OKStore and pop single precisionD9 /3fstps [mem]
fstpt✅ OKStore 80-bit extended precision & popDB /7fstpt [mem]

Arithmetic Operations

InstructionStatusDescriptionOpcodeExample
fadd✅ OKAdd floating-point valuesD8 /0fadd st(1), st
faddl✅ OKAdd long double from memoryDA /0faddl [mem]
fsub✅ OKSubtract floating-point valuesD8 /4fsub st(1), st
fsubp✅ OKSubtract with popDE /5fsubp st(1), st(0)
fmul✅ OKMultiply floating-point valuesD8 /1fmul st(1), st
fdiv✅ OKDivide floating-point valuesD8 /6fdiv st(1), st
fdivp✅ OKDivide with popDE /7fdivp st(1), st(0)
fscale✅ OKScale ST(0) by ST(1)D9 FDfscale

Comparison

InstructionStatusDescriptionOpcodeExample
fcom✅ OKCompare floating-point valuesD8 /2fcom st(1)
fucom✅ OKUnordered compare ST(0) with ST(i)DD E0+ifucom st(1)
fucomp✅ OKUnordered compare and popDD E8+ifucomp st(1)
ftst✅ OKCompare ST(0) with 0.0D9 E4ftst

Stack Manipulation

InstructionStatusDescriptionOpcodeExample
fxch✅ OKExchange ST(0) with ST(i)D9 C8+ifxch st(1)
fchs✅ OKChange sign of ST(0)D9 E0fchs
fabs✅ OKAbsolute value of ST(0)D9 E1fabs
frndint✅ OKRound ST(0) to integerD9 FCfrndint

Logarithmic and Special Math Operations

InstructionStatusDescriptionOpcodeExample
fyl2x⏳ TBDCompute y × log₂(x) and popD9 F1fyl2x
fyl2xp1❌ N/ACompute y × log₂(x+1) and popD9 F9fyl2xp1
fxtract❌ N/AExtract significand and exponent from ST(0)D9 F4fxtract
f2xm1✅ OKCompute 2^x - 1 for ST(0)D9 F0f2xm1
fpatan❌ N/ACompute arctangent and popD9 F3fpatan
fsqrt❌ N/ACompute square root of ST(0)D9 FAfsqrt

Visit the Releases section to find precompiled kernel images with FPU emulation capability, as well as related drive images.

0 comments

No comments yet.

Sign in to be the first to comment.