VOGONS


SVN on OS X - core=dynamic causes segfault

Topic actions

Reply 100 of 110, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

grrr, accidently compiled it with clang and that is known to not work correctly with Dosbox, no matter what arch... Sorry.

With pointing at llvm-gcc
(gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00))
both patches work fine.
Funnily they seem to trigger some kind of overflow in the PCPbench. Sometimes they score around 53fps but often 02.1fps (Gulikozas patch) or 02.2fps (ripsaws patch) (if I set cycles to 12000 I get around 2.3fps (without the leading 0).

32bit built scores over 100fps but is probably so fast it has tearing in the benchmark 😀

So, both patches work, Ripsaws is very slightly faster.

The clang problem is a different issue...

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 101 of 110, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Unfortunately it seems the graphics part of the dynamic core is highly unstable. Can be seen by running stuff in Windows 3.x in Dosbox. Run any program in it and its window size is much bigger than the desktop size 🙁

Edit: and this is again *fixed* by using old Apple gcc instead of the one that comes with current xcdoe 🙁

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 103 of 110, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

I have no idea on how to do anything there...

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 104 of 110, by gulikoza

User metadata
Rank Oldbie
Rank
Oldbie

Maybe something like this:

 static void gen_mov_word_to_reg_imm(HostReg dest_reg,Bit16u imm) {
- cache_addb(0x66);
cache_addb(0xb8+dest_reg); // mov reg,imm
- cache_addw(imm);
+ cache_addd((Bit32u)imm);

http://www.si-gamer.net/gulikoza

Reply 105 of 110, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Unfortunately, no go 🙁

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 106 of 110, by gulikoza

User metadata
Rank Oldbie
Rank
Oldbie

Ok, let's do the 8-bit versions as well 😀

diff --git a/src/cpu/core_dynrec/risc_x64.h b/src/cpu/core_dynrec/risc_x64.h
--- a/src/cpu/core_dynrec/risc_x64.h
+++ b/src/cpu/core_dynrec/risc_x64.h
@@ -146,7 +146,7 @@ static void gen_mov_word_from_reg(HostReg src_reg,void* dest,bool dword) {
// this function does not use FC_OP1/FC_OP2 as dest_reg as these
// registers might not be directly byte-accessible on some architectures
static void gen_mov_byte_to_reg_low(HostReg dest_reg,void* data) {
- cache_addb(0x8a); // mov reg,[data]
+ cache_addw(0xb60f); // movzx reg,[data]
gen_reg_memaddr(dest_reg,data);
}

@@ -155,8 +155,7 @@ static void gen_mov_byte_to_reg_low(HostReg dest_reg,void* data) {
// this function can use FC_OP1/FC_OP2 as dest_reg which are
// not directly byte-accessible on some architectures
static void gen_mov_byte_to_reg_low_canuseword(HostReg dest_reg,void* data) {
- cache_addb(0x66);
- cache_addb(0x8b); // mov reg,[data]
+ cache_addw(0xb60f); // movzx reg,[data]
gen_reg_memaddr(dest_reg,data);
}

@@ -165,8 +164,8 @@ static void gen_mov_byte_to_reg_low_canuseword(HostReg dest_reg,void* data) {
// this function does not use FC_OP1/FC_OP2 as dest_reg as these
// registers might not be directly byte-accessible on some architectures
static void gen_mov_byte_to_reg_low_imm(HostReg dest_reg,Bit8u imm) {
- cache_addb(0xb0+dest_reg); // mov reg,imm
- cache_addb(imm);
+ cache_addb(0xb8+dest_reg); // mov reg,imm
+ cache_addd((Bit32u)imm);
}

// move an 8bit constant value into dest_reg
@@ -174,9 +173,8 @@ static void gen_mov_byte_to_reg_low_imm(HostReg dest_reg,Bit8u imm) {
// this function can use FC_OP1/FC_OP2 as dest_reg which are
// not directly byte-accessible on some architectures
static void gen_mov_byte_to_reg_low_imm_canuseword(HostReg dest_reg,Bit8u imm) {
- cache_addb(0x66);
cache_addb(0xb8+dest_reg); // mov reg,imm
- cache_addw(imm);
+ cache_addd((Bit32u)imm);
}

// move the lowest 8bit of a register into memory

http://www.si-gamer.net/gulikoza

Reply 107 of 110, by dukzcry

User metadata
Rank Newbie
Rank
Newbie

I currently use this simple script to build DOSBox w dynamic core support (so i386 version) on modern OS X:

brew install --universal sdl
brew install --universal sdl_net
#brew install --universal fluidsynth

CFLAGS='-g -O2 -arch i386'
CXXFLAGS=$CFLAGS
export CFLAGS CXXFLAGS

./configure --host=i386-apple-darwin 2>error.log
make -j8

#brew remove sdl
#brew remove sdl_net
#brew remove fluidsynth

Works fine.
SDL and SDL_net are built by homebrew. Still have no source for i386 libfluidsynth (MIDI sound).

Reply 108 of 110, by gulikoza

User metadata
Rank Oldbie
Rank
Oldbie

Here's the updated patch. It comes after memaddr patch as I consider that one higher priority.

A bugzilla report on GCC indicates that all parameters should be extended in the caller to at least 32-bits. GCC currently does extension in the callee as well so dynrec works. But other compilers might not.

There remains a question how to extend the parameters (zero or sign), since the core doesn't always know if the integer is signed, but maybe it does not matter if the called function uses only part of the register?
Can somebody test this? 😀

Attachments

  • Filename
    risc64.diff
    File size
    3.12 KiB
    Downloads
    63 downloads
    File license
    Fair use/fair dealing exception

http://www.si-gamer.net/gulikoza

Reply 109 of 110, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

I am leaving this open for now, given the question. wjp might be able to help you

Water flows down the stream
How to ask questions the smart way!