Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FPU status word bits 0-5 never set (FNSTSW AX) #3507

Open
2 tasks done
pcdosretro opened this issue May 20, 2022 · 4 comments
Open
2 tasks done

FPU status word bits 0-5 never set (FNSTSW AX) #3507

pcdosretro opened this issue May 20, 2022 · 4 comments
Labels

Comments

@pcdosretro
Copy link

pcdosretro commented May 20, 2022

Describe the bug

Even if floating point exceptions are disabled, the FPU status word should be set to indicate floating point errors.

I suspect that denormalized operands (bit 1) and precision (bit 5) would be a lot to emulate but certainly invalid operation (bit 0), zero divide (bit 2), overflow (bit 3), and underflow (bit 4) should be set.

Steps to reproduce the behaviour

DEBUGX
a
fninit
fld1
fchs
fsqrt
fnstsw ax
int 3

g
r
rn
q

Bit 0 in AX should be set to indicate an invalid operation sqrt(-1)


DEBUGX
a
fninit
fld1
fldz
fdivp
fnstsw ax
int 3

g
r
rn
q

Bit 2 in AX should be set to indicate a zero divide error

Expected behavior

No response

What operating system(s) this bug have occurred on?

Windows 7 SP 1 64-bit

What version(s) of DOSBox-X have this bug?

0.83.25, 0.84.0 (64-bit builds only)

Used configuration

No response

Output log

No response

Additional information

No response

Have you checked that no similar bug report(s) exist?

  • I have searched and didn't find any similar bug report.

Code of Conduct & Contributing Guidelines

  • I agree to follow the code of conduct and the contributing guidelines.
@pcdosretro pcdosretro added the bug label May 20, 2022
@pcdosretro
Copy link
Author

Adding fxam before fnstsw ax in either of those shows it doesn't set the condition code properly either since bit 8 should be set as neither of the results are valid numbers (NaN or +infinity)

@pcdosretro
Copy link
Author

This is only an issue in 64-bit builds. 32-bit builds use the inline assembly in fpu_instructions_x86.h which handles everything properly. The 32-bit builds of DOSBox-X work fine. I'm switching to the 32-bit builds.

@joncampbell123
Copy link
Owner

64-bit Linux here. I entered your steps in DEBUG and the bits you indicate are set as specified.

@pcdosretro
Copy link
Author

This is similar to #3451 in that the MSVC compiler doesn't support 64-bit inline assembly so the emulation would have to handle the exception bits. Apparently GCC (and likely Clang) does support 64-bit inline assembly so fpu_instructions_x86.h is used.

I will leave it up to you if you want to close this and #3451 since both are caused by the MSVC compiler lacking support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants