i387 FPU not used on x86_64?

Here you can discuss the development of patches.

i387 FPU not used on x86_64?

Postby jukivili » 2011-10-22 @ 22:18

Hello,

I tried Carmageddon 1 with dosbox-0.74, got those horrible vertical bars. So I searched for solution and found out about 80bit vs 64bit floating point issue. Then I checked code and saw that on 32bit x86 dosbox uses i387 fpu using assembler macros and started wondering why it is not used for x86_64 (as it's perfectly allowed to use i387 FPU in 64bit mode).

So I hacked a bit,

1. added some #ifdef __x86_64__ ... #else ... #endif to fpu_instructions_x86.h
2. made new x86_64 macros for gcc (simply by renamed all %eax => %rax, all movl/incl/decl/shll/[op]l => movq/incq/decq/shlq/[op]q, that's all)
3. Edited configure.in to enable x86 assembler fpu on x86_64

And it just worked on first run, Carmageddon 1 on x86_64 dosbox without graphics glitch.

So do you want me to send patch for this? I really would not want to touch the MSVC part and this really is trivial fix anyways.
jukivili
Newbie
 
Posts: 4
Joined: 2011-10-22 @ 22:05

Re: i387 FPU not used on x86_64?

Postby wd » 2011-10-23 @ 11:47

x86 builds are a lot faster anyways so not much point in using a 64bit build.
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: i387 FPU not used on x86_64?

Postby jukivili » 2011-10-23 @ 13:42

Linux distributions don't provide 32bit dosbox on x86_64.

And building working dosbox required building required 32bit libraries... adding i387 FPU to x86_64 build of dosbox is less work than that.
jukivili
Newbie
 
Posts: 4
Joined: 2011-10-22 @ 22:05

Re: i387 FPU not used on x86_64?

Postby Qbix » 2011-10-23 @ 13:48

I don't mind seeing the patch. Won't promise that I will put it in, but I am curious. My 64 bit asm is none existent
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10652
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: i387 FPU not used on x86_64?

Postby jukivili » 2011-10-23 @ 18:42

Is it ok to leave MSVC asm out? I don't how to do 64bit asm on with it, and would not have means to test it.

Also is patch over 0.74 ok, or should it be over latest svn version?
jukivili
Newbie
 
Posts: 4
Joined: 2011-10-22 @ 22:05

Re: i387 FPU not used on x86_64?

Postby wd » 2011-10-23 @ 19:05

I don't know if linux installations really have that many problems, but since windows doesn't it's fine to stick to gcc (mingw if you can/want to test that).
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: i387 FPU not used on x86_64?

Postby jukivili » 2011-10-24 @ 18:50

I decided to do some refactoring. Instead of duplicating all fpu macros for x86_64, I modified existing ones to work on both 32bit and 64bit (as maintaining duplicates would mean more work).

Patch does following:

1. Rename all %%eax => to AX macro, which is defined as:
#ifdef __x86_64__
#define AX "rax"
#else
#define AX "eax"
#endif

So that 64bit "rax" is used on x86_64 and 32bit "eax" on i386.

2. Remove instruction operation size modifiers (trailing Ls from ops), gcc so that selects correct type by itself (for example, movl on 32bit, movq on 64bit).

3. Modify configure.in to enable x86-fpu on x86_64.

Tested on x86_64 linux, compile tested on i386 linux.
You do not have the required permissions to view the files attached to this post.
jukivili
Newbie
 
Posts: 4
Joined: 2011-10-22 @ 22:05

Re: i387 FPU not used on x86_64?

Postby Tobis87 » 2011-10-29 @ 15:46

jukivili wrote:Is it ok to leave MSVC asm out? I don't how to do 64bit asm on with it, and would not have means to test it.

It does not work with MSVC anyway, because there is no 64bit Inline Assembler support. They only support Compiler Intrinsics.

However I tried to compile it with the Intel C Compiler, also by changing eax to rax and ebx to rbx. But it does not work, I always get "error: operand size mismatch -- __asm mov".

I don't know maybe because Windows uses the LLP64 Modell instead of LP64. But I would like to have this enabled as well, if someone has an idea...
Tobis87
Newbie
 
Posts: 14
Joined: 2010-1-19 @ 18:04

Re: i387 FPU not used on x86_64?

Postby wd » 2011-10-29 @ 17:32

As already pointed out it's useless for win64 since it runs 32bit executables just fine.
I was not aware that 64bit linux has *that* gross problems in some distros but
that may just be a move of focus anyways.
If you're really interested then check out the c-based recompiler which should be
in a quite good shape for 64bit windows albeit non-working. It does not need any
assembler blocks at all.
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: i387 FPU not used on x86_64?

Postby Sorceror » 2012-1-10 @ 16:49

Oops, didn't see the download for the patch.
Sorceror
Newbie
 
Posts: 1
Joined: 2012-1-10 @ 16:47
Location: Australia


Return to DOSBox Patches

Who is online

Users browsing this forum: No registered users and 1 guest