FPU math errors

Developer's Forum, for discussion of bugs, code, and other developmental aspects of DOSBox.

FPU math errors

Postby Shane32 » 2018-1-01 @ 15:45

I'm having problems with the fpu enabled on DosBox-X 12-31-2017. To illustrate, this one-line BASIC program returns 0 (false) instead of -1 (true):

PRINT VAL("1") = 1

With the FPU turned off it works fine. I've tried all the core and cpu settings, but no matter what, the example above fails whenever the fpu is enabled. This can be seen in the BASIC game NIBBLES (included with MS-DOS 5) where the game will not accept a response to "number of players?", or the game Operation Neptune, in which the built-in calculator always responds with "answer too large" and will not accept a correct answer.

Is this a bug in the fpu emulation? Or is there another setting I'm missing to properly emulate a 80486DX2 (which should include a fpu)? It would seem that when core=simple, the fpu should simulate a fpu from that era, even if the answers are a bit different from when core=dynamic.

Note that the problem does not occur with Dosbox 0.74. I'm guessing it does not emulate the fpu at all.

My setup is:
Doxbox-X 12-31-2017 build
Windows 10 64 bit
Intel Core i7-7567U 3.5GHz / 16GB RAM / integrated graphics

My config is:
Code: Select all

I'm using MS PDS 7.1 BASIC within DosBox.

User avatar
Posts: 12
Joined: 2018-1-01 @ 15:28

Re: FPU math errors

Postby Zup » 2018-1-01 @ 16:18

You should check it on a real DOS machine, because this may be a BASIC issue.

I mean... what kind of data is 1 and what kind of data returns VAL()? Maybe you are comparing a integer number with a float, and in some languages this can lead to unexpected results.
I have traveled across the universe and through the years to find Her.
Sometimes going all the way is just a start...

I'm selling some stuff!
User avatar
Posts: 1049
Joined: 2003-10-04 @ 12:16

Re: FPU math errors

Postby collector » 2018-1-01 @ 16:19

You might want to post this in the DOSBox-X thread to be sure that TheGreatCodeholio sees it.

User avatar
Posts: 4076
Joined: 2003-1-15 @ 10:39

Re: FPU math errors

Postby Shane32 » 2018-1-01 @ 17:54

You're correct - VAL returns a double, and then it's compared to an integer. With single-precision variables, there isn't a problem.

I don't know about the rest, but I never remember a problem with NIBBLES or Operation Neptune on my old 486DX2-66 machine that I grew up on.

There is a MS KB article about comparisons in BASIC, but ... it did work ...
https://support.microsoft.com/en-us/hel ... n-problems

I have not found any FPU-testing programs online. So for now I'll just leave the fpu disabled. None of the software I'm emulating requires a fpu anyway.
User avatar
Posts: 12
Joined: 2018-1-01 @ 15:28

Re: FPU math errors

Postby BlackJack » 2018-1-24 @ 00:46

Shane32 wrote:Note that the problem does not occur with Dosbox 0.74. I'm guessing it does not emulate the fpu at all.

Dosbox 0.74 seems to always have an FPU. I wasn't able to configure it so that this simple test program doesn't detect an FPU:

Code: Select all
; nasm fpu_test.asm -o fpu_test.com

    cpu 8086
    org 100h

    mov     dx, no_fpu_txt
    fnstsw  [fpu_status]
    cmp     word [fpu_status], 0
    jne     .nope
    fnstcw  [fpu_control]
    cmp     word [fpu_control], 037fh
    jne     .nope

    mov     dx, fpu_txt
    mov     ah, 09h
    int     21h
    mov     ax, 4c00h
    int     21h

    db "No "
    db "FPU found", 13, 10, '$'

    dw  0ffffh
    dw  0ffffh

The setting `fpu=false` is neither documented in the config file or man page, nor does it have any effect on my 0.74 installation.
Source & COM
(614 Bytes) Downloaded 5 times
“The city's central computer told you? R2D2, you know better than to trust a strange computer!” — C3PO
Posts: 1
Joined: 2018-1-23 @ 19:22
Location: Berlin

Return to DOSBox Development

Who is online

Users browsing this forum: No registered users and 3 guests