• Please review our updated Terms and Rules here

DJGPP and floating point emulation.

Tape_Worm

New Member
Joined
Oct 14, 2023
Messages
3
This is probably a stupid question combined with my faulty memory playing tricks on me.

For fun, I created a stupid little thing in DJGPP (v2.03) on 86box, emulating a 25 MHz 486 SX - no FPU - just like a machine I had years ago. Because the machine, real and virtual, has no FPU, DJGPP uses a floating point emulation library (emu387.dxe/libemu.a).

Here's the issue: I know that FP emulation is slow, but something's not right. I just timed my SIN/COS table generating code, and it's taking 2.78 seconds to generate the tables using FPU emulation. For a loop of 360 degrees and that seems like a stupidly long amount of time, even for FPU emulation on a 25 MHz 486. So, just for giggles, I wrote the same SIN/COS table generating code in Turbo Pascal 6.0 and generated the tables nearly instantly (and I confirmed the approximate values were good enough for what I was doing). This seems really weird to me and I don't recall there being this much of a performance hit when I used DJGPP 2.03 on my old 486 back in the day (this could also be a potentially faulty memory on my part... I'm getting old).

It could be 86box is causing a problem here, but I would have expected the TP6 code to be affected by it too (obviously, it could still be a quirk in the emulator - different compiler tech and all).

Would anyone have any insight into this? Am I just remembering incorrectly and it's always been this slow?
 
Last edited:
I don't know how accurate the 86box emulation is - you might have hit a bug there. Instead, try to emulate a 486DX and change the compiler settings for FPU/emulation mode to compare.

There are different approaches to FPU emulation, trading accuracy vs. code size vs. speed. It is possible that your version of DJGPP ships with an accurate but very slow emulation, assuming that most users will have an FPU. Turbo Pascal may have catered to lower-end systems without FPU instead. Most code at the time didn't rely on floating-point types in the first place (or only very little), tainting your memory.
 
Thanks for the insight, I really appreciate it.

I'm leaning towards this being an issue with 86box emulation. And while I know DOSBOX (and DOSBOX-X) aren't accurate at all, they appear to run the code in a very short amount of time, even at 250 cycles (that is, on DOSBOX-X, which allows me to disable the FPU and use emulation).

Computers are hard yo. 😐
 
Back
Top