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

fldpi only loads pi to 53-bit accuracy instead of 64-bit accuracy #3451

Closed
2 tasks done
pcdosretro opened this issue May 3, 2022 · 6 comments · Fixed by #5199
Closed
2 tasks done

fldpi only loads pi to 53-bit accuracy instead of 64-bit accuracy #3451

pcdosretro opened this issue May 3, 2022 · 6 comments · Fixed by #5199
Labels

Comments

@pcdosretro
Copy link

pcdosretro commented May 3, 2022

Code of Conduct & Contributing Guidelines

  • I agree to follow the code of conduct and the contributing guidelines.

Have you checked that no other similar bug report(s) already exists?

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

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)

Describe the bug

fldpi only loads pi to 53-bit accuracy instead of 64-bit accuracy. The fraction loaded is C90FDAA2 2168C000

This is also true of the instructions fldl2t, fldl2e, fldlg2, fldln2

Expected behavior

fldpi should load the fraction C90FDAA2 2168C234

Steps to reproduce the behaviour

Get DEBUG or DEBUGX from my website - https://pcdosretro.github.io/enhdebug.htm

a
fninit
fldpi
fstp tbyte ptr [80]
int 3

g
d 80 la

Used configuration

No response

Emulator log

No response

Additional context

No response

@pcdosretro pcdosretro added the bug label May 3, 2022
@cimarronm
Copy link
Contributor

On anything compiling for an x86 platform with the C_FPU_X86 define set, it will use the fldpi instruction itself in emulation so this shouldn't be a problem. On compiler/platform combinations which support a long double type, PR #3453 should allow it to fill the full 64-bit mantissa. BTW, I am getting a mantissa of 0xc90fdaa22168c235 (instead of 0xc90fdaa22168c234 as you listed) which is closer to PI.

0x4000c90fdaa22168c235 = 3.14159265358979323851...
0x4000c90fdaa22168c234 = 3.14159265358979323829...
PI = 3.14159265358979323846...

@pcdosretro
Copy link
Author

The Intel manual says FLDPI loads C90FDAA2 2168C234 C which gives you 3.141592653589793238
I will recheck it with v0.83.26 which should have your fix for this (and hopefully a fix for my previous FPU bug #3440)

@pcdosretro
Copy link
Author

pcdosretro commented Jun 1, 2022

Not fixed in DOSBox-X 0.84.0 - somewhere long double values are getting demoted to double.

debugx_000

debugx_001

@pcdosretro
Copy link
Author

pcdosretro commented Jun 1, 2022

The problem here is the damn MSVC compilers don't actually support long double as 80-bit floating point, long double is the same as double. The sad thing is the old 16-bit DOS MS C compilers did in fact support long double as 80-bit floating point. Another problem is that MSVC doesn't support 64-bit inline assembly so the inline assembly in fpu_instructions_x86.h can't be used.

The 32-bit builds of DOSBox-X work fine.

@cimarronm
Copy link
Contributor

Yeah, unfortunately microsoft decided not to support the extended precision long double nor inline assembly in the 64-bit version of the compiler. The MinGW 64-bit version for windows should support C_FPU_X86 and give you a 64-bit version with the x87 instruction set.

@pcdosretro
Copy link
Author

I switched to the 32-bit build which works fine. Technically this isn't a bug in DOSBox-X so I guess this can be closed.

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

Successfully merging a pull request may close this issue.

2 participants