joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.65k stars 376 forks source link

fpu=false strange behaviour #1968

Closed rderooy closed 3 years ago

rderooy commented 3 years ago

Describe the bug Setting fpu=false seems to have strange behaviour. In short it seems ignored.

It should be possible to disable the FPU on 8086 up-to and including the 486. It should be ignored on the Pentium.

When I specify -set fpu=false (running config -get fpu afterwards confirms it is set to false). This works with EVERY cpu type, even with Pentium class CPUs which always have a FPU.

However, setting fpu=false and running it with cputype=486 and starting Symantec System Information 8.0 shows that it detects an FPU. sysinfo_000

And the same with Landmark Speed Test lm60_000

Likewise CPU-ID also reports a 486 with FPU... command_000

I thought this was partly an issue with CPU-ID, and it may well be. The reported CPU-ID is 0402 which is a 486DX25 or 486DX33 with a stepping of C0. While if the FPU is disabled, it should change to something like 0422, or in case the SL-Enhanced feature is emulated 0423 for an 486SX CPU and 0414 for the 486DX CPU. http://datasheets.chipdb.org/Intel/x86/486/Intel486.htm

But when I then tried it with cputype=386, I also noticed problems. sysinfo_001 lm60_001

Or cputype=286 sysinfo_002 lm60_002

Or cputype=80186 (SI requires at least a 286) lm60_003

Or cputype=8086 lm60_004

Additional context You can find various tools and benchmarks in Phil's benchmark pack. But note that the included CPUID tool does not work properly in DOSBox-X for most CPU types. Instead get the newer https://www.philscomputerlab.com/dos-benchmark-pack.html p.s. the Speedsys benchmark (386+ only) just hangs with an endless stream of LOG: 344635914 ERROR CPU:Write 0 to rom at f595f errors to the log.

rderooy commented 3 years ago

I tried to adjust the code in cpu.cpp, but when I then try to run the CPUID test, it still reports 0402 even with fpu=false.

if ((CPU_ArchitectureType == CPU_ARCHTYPE_486NEW) ||
                        (CPU_ArchitectureType == CPU_ARCHTYPE_MIXED)) {
                        reg_eax=enable_fpu?0x402:0x422;       /* intel 486dx or 486sx */
                        reg_ebx=0;                      /* Not Supported */
                        reg_ecx=0;                      /* No features */
                        reg_edx=enable_fpu?1:0;       /* FPU */
Wengier commented 3 years ago

@rderooy I think I see what is happening with -set fpu=false. There are two fpu config options in the config file, the first one in the [log] section, and the second one in the [cpu] section. So if you just specify -set fpu=false from the command-line, then it will apply to the fpu setting in the [log] section, not the [cpu] section. Thus for this case you need to specify -set "cpu fpu=false" instead. Please check this out.

Wengier commented 3 years ago

@rderooy I decided to change the algorithm so that if there is a setting in both the [log] section and the other section, and you specify the setting without the section, then it will default to the other section. Thus, with the latest code -set fpu=false should now work as you had expected previously.

rderooy commented 3 years ago

Ahh ok, that makes sense. Sorry for the confusion.

On Wed, Oct 28, 2020 at 11:29 PM Wengier notifications@github.com wrote:

@rderooy https://github.com/rderooy I decided to change the algorithm so that if there is a setting in both the [log] section and the other section, and you specify the setting without the section, then it will default to the other section. Thus, with the latest code -set fpu=false should now work as you had expected previously.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/joncampbell123/dosbox-x/issues/1968#issuecomment-718245355, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEHBR2VPAWWSSIHMUTN5LF3SNCLNTANCNFSM4TCR6NTQ .

Wengier commented 3 years ago

@rderooy I think it is helpful to be addressed anyway. Thanks for letting me aware of it.

RNMB15 commented 3 years ago

You can insert the following CPU types, 386SX, 486SX without internal FPU, 386DX, 486DX with internal FPU.

rderooy commented 3 years ago

@RNMB15 CPU-ID was only introduced with the later model 486 CPU's. Early 486 models lack support for it. So you cannot add it for 386 CPUs.

Also, neither the 386SX or 386DX have a FPU. In both cases you had to purchase a i387 separately. The difference is that the 386DX is 32-bit internal and external, while the 386SX has an external 16-bit data path to reduce systemboard cost. Basically PC manufacturers could reuse their 286 systemboards designs for the most part. Although obviously at a performance cost.

I don't know if you can really detect from software if it is a 386SX or 386DX.

joncampbell123 commented 3 years ago

@rderooy @RNMB15 I've also heard of early 486SXs without an FPU, not because it's not there but because the FPU part was defective and therefore disabled before shipping.

https://retrocomputing.stackexchange.com/questions/12109/were-there-486sx-revisions-without-an-fpu-on-the-die

rderooy commented 3 years ago

@joncampbell123 correct. To increase yield, some 486SX CPU's where in fact 486DX parts with the FPU disabled. But in that case (assuming they support CPU-ID), should report themselves as SX parts.

RNMB15 commented 3 years ago

Can you add an option to the dosbox config at (CPU) where you can determine whether the FPU should be emulated internally or externally at 386 or 386?

joncampbell123 commented 3 years ago

@RNMB15 386s do not have an internal FPU, but you can externally add an FPU. But such an option would be appropriate for 486 emulation.

rderooy commented 3 years ago

@RNMB15 Perhaps I'm not understanding you properly.

As @joncampbell123 mentioned the FPU was never internal to the 386 (or earlier) generation CPUs. It only became internal with the 486 (subsequently called the 486DX). But at that point Intel still offered a cheaper version without integrated FPU, the 486SX. From the Pentium onward such an option was no longer offered, so a Pentium (and later generations) always have an FPU.

In any case, DOSBox and by extension DOSBox-X by default emulates an FPU for any supported CPU type. So FPU emulation is already in place and enabled.

One thing that vanilla DOSBox does not support is disabling the FPU, it is always enabled. With DOSBox-X you can disable the FPU by setting fpu=false in the [cpu] section.

One thing that I don't quite agree with though is that DOSBox-X allows you to disable the FPU even on Pentium class CPUs, while such CPUs always had an FPU.

joncampbell123 commented 3 years ago

@rderooy DOSBox-X lets you tweak things however you like. In my particular style of giving the user options, an option to disable the FPU even for Pentium class processors should at most print a warning in the console and logfile saying that the configuration is very unusual and software written for the Pentium may not work properly but allow you to see for yourself anyway.

Wengier commented 3 years ago

@joncampbell123 I have already added a warning in the console/logfile saying that such configuration is unusual and may confuse DOS programs in the latest code.