x87 co-processor emulator? A real thing or totally fake?

Getting old software/games running on older hardware.

x87 co-processor emulator? A real thing or totally fake?

Postby GigAHerZ » 2019-1-04 @ 11:59

Wandering around the interent, i've found some programs/TSRs, that claim they can emulate maths co-processor in software. Of course slower than real hardware, but better than nothing...

With few of them i did a quick test by trying to start quake, but all of them failed.

At the same time, in theory, emulating x87 co-processor might be possible. You could use precalculated hashmap's and you could sacrifice some precision, by filling gaps between precalculated values linearly. (This makes it quite fast!) Many older games on PC and also on NES and other weaker consoles often approaced these challenges like that. (Calculated 8-16 values of sin, cos, tan etc and filled the caps linearly)

So in the end, in real life, are there any x87 emulators that actually do work?
"640K ought to be enough for anybody." - And i intend to get every last bit out of it even after loading every damn driver!
User avatar
GigAHerZ
Member
 
Posts: 230
Joined: 2018-12-17 @ 15:35
Location: Estonia

Re: x87 co-processor emulator? A real thing or totally fake?

Postby Scali » 2019-1-04 @ 12:21

There are various types of x87 emulators.
Back in the early days, there was a standard for this, used by various compilers. They would pre-pend x87 instructions with a software interrupt. The TSR would be installed in that interrupt, and emulate the instruction directly after the interrupt when no x87 was installed, or just return and let a real x87 handle it.
In some cases, these emulators were compiled directly into the binary (as you can see with Turbo Pascal/Turbo C++ code for example), so no TSR was required.

Obviously this requires that the application is compiled with support for the x87 emulator.
On newer CPUs it became possible to virtualize instructions directly, so a different type of x87 emulator became possible, and no specific code was required in the application.

So yes, x87 emulators are a thing, and they definitely do work (they do not go for tables and approximations however, they are specifically designed to emulate the x87 as closely as possible. Tables and approximations are better coded directly into the application).

I doubt they would work with a game like Quake though, since it uses a DOS extender, and basically completely takes over the machine and creates its own virtualized environment. The x87 emulator would likely no longer function.
Scali
l33t
 
Posts: 4170
Joined: 2014-12-13 @ 14:24

Re: x87 co-processor emulator? A real thing or totally fake?

Postby Jo22 » 2019-1-04 @ 14:43

I second that, Scali explained that very well IMHO.

This perhaps is slightly off-topic, but on Windows 2.x and 3.x, there's also a runtime named WIN87EM which both virtualizes and
emulates a simple x87 math coprocessor. Even if a real x87 is installed, virtualization might be necessary in order to allow multiple
Windows programs to access the math coprocessor at the same time. That runtime also saves and restores the state of the real FPU
from time-to-time, to make sure the different programs don't get into each others way.
"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//
User avatar
Jo22
l33t
 
Posts: 3681
Joined: 2009-12-13 @ 07:06
Location: Europe

Re: x87 co-processor emulator? A real thing or totally fake?

Postby Scali » 2019-1-04 @ 15:21

Jo22 wrote:This perhaps is slightly off-topic, but on Windows 2.x and 3.x, there's also a runtime named WIN87EM which both virtualizes and
emulates a simple x87 math coprocessor. Even if a real x87 is installed, virtualization might be necessary in order to allow multiple
Windows programs to access the math coprocessor at the same time. That runtime also saves and restores the state of the real FPU
from time-to-time, to make sure the different programs don't get into each others way.


Yes, the FPU has its own registers. The state of the registers are known as the 'context'. And in multitasking/multithreading, switching from one task to the next is known as a context switch.
So indeed, a multitasking environment needs to also switch the FPU context if you want to share the FPU between tasks.
For this exact reason, Intel decided to implement the MMX extension by re-using the FPU context instead of adding new registers. The advantage is that any multitasking environment with support for x87 would automatically work with MMX without any changes.
AMD's 3DNow! again was an extension of MMX, re-using the same registers, for the same reason.

When Intel later introduced SSE, they did add new registers, but now you needed an OS update in order to make use of SSE (or well, in practice you could run one SSE task, because its state would not get corrupted by any other tasks, but as soon as you'd run a second SSE task, the results would be undefined).
Scali
l33t
 
Posts: 4170
Joined: 2014-12-13 @ 14:24

Re: x87 co-processor emulator? A real thing or totally fake?

Postby Jo22 » 2019-1-05 @ 18:07

Thanks for the explanation, Scali! :)
I remember some of this, but did forget the details and technical terms. :sweatdrop:
"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//
User avatar
Jo22
l33t
 
Posts: 3681
Joined: 2009-12-13 @ 07:06
Location: Europe

Re: x87 co-processor emulator? A real thing or totally fake?

Postby kixs » 2019-1-05 @ 18:38

They usually work with apps. Like Autocad,... MIght even work with Falcon 3.0. Don't remember anymore.

Try Q387:
https://www.pcorner.com/list/UTILITY/Q387_32B.ZIP/INFO/
My Amibay: SALE | BUY - Updated on 2019-07-04
User avatar
kixs
l33t
 
Posts: 2279
Joined: 2013-1-31 @ 02:08
Location: Slovenia, EU

Re: x87 co-processor emulator? A real thing or totally fake?

Postby GigAHerZ » 2019-1-05 @ 20:46

Thank you guys for the answers!

I'll definitiely try those through second time. This time i'll try to get my hands on falcon 3.0 and maybe some autocad software to check it out.

Any other suggestions to try out to see the performance of emulated 387?
"640K ought to be enough for anybody." - And i intend to get every last bit out of it even after loading every damn driver!
User avatar
GigAHerZ
Member
 
Posts: 230
Joined: 2018-12-17 @ 15:35
Location: Estonia

Re: x87 co-processor emulator? A real thing or totally fake?

Postby Jo22 » 2019-1-05 @ 21:28

Hm. Some benchmark programs display x87 performance graphically as a bar (CheckIt!, NSSI etc).
Also visually interesting are fractal programs (Mandelbrot), though they also use integer math sometimes.

And some old CAM/CAM programs (I've recorded some clips of AutoSketch) or old PCB layout software (eagle, etc.).
Autodesk 3D Studio (DOS) also was popular. If memory serves, it supported some extensions of the ITT or Cyrix 387 FPUs.

In QuickBasic, there's the torus.bas sample program which is said to make use of x87 if available (if run via QB IDE).
As part of the Weitek diskette, there's a little beach ball like benchmark - one for Weitek and one for 387.

In Windows 3.1, the MOD4WIN player can use x87 for the IDO filter. Though I don't know if this increases performance or audio fidelity.
Speaking of Windows, I don't know if DOS TSRs for x87 emulation still work. If so, GDI itself may also benefit from x87 if available.

Hm. Maybe in Real-Mde of Win 2.x or 3.0 they still do..
If you want to give it a try, you can try this Mandelbrot program for Win 2.0+
Attachments
mndlpic.zip
Mandelbrot generator;
Windows (real-mode). V2.x and up.
(22.92 KiB) Downloaded 3 times
"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//
User avatar
Jo22
l33t
 
Posts: 3681
Joined: 2009-12-13 @ 07:06
Location: Europe


Return to Software

Who is online

Users browsing this forum: No registered users and 4 guests