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

Dynamic core FPU emulation/JIT broken on ARM64/Apple Silicon macOS #3890

Open
badlogic opened this issue Dec 19, 2022 · 4 comments
Open

Dynamic core FPU emulation/JIT broken on ARM64/Apple Silicon macOS #3890

badlogic opened this issue Dec 19, 2022 · 4 comments

Comments

@badlogic
Copy link
Contributor

Describe the bug

The dynamic core FPU JIT/emulation appears to be broken on Apple Silicon when using DOSBox-x for Apple Silicon. This trivial C program

#include <stdio.h>

int main(void) {
    double v = 123.0;
    printf("%f", v);
    return 0;
}

will "print" the following

Screenshot 2022-12-19 at 01 07 41

Steps to reproduce the behaviour

  1. Compile the above program with DJGPP (any version will do, I tested 12.1.0 and 7.5.0). I've attached an executable: dos.zip
  2. Run the executable using DOSBox-X for Apple Silicon on an Apple Silicon macOS machine
  3. See

Expected behavior

The program should print 123.0.

Note that DOSBox-x x86_64 for macOS running on Apple Silicon via Rosetta 2 works as intended.

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

macOS on Apple Silicon

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

0.84.1, latest commit on GitHub

Used configuration

No response

Output log

LOG: Early LOG Init complete
LOG: "65536" is not a valid value for variable: pcrate.
It might now be reset to the default value: 65536
LOG: DOSBox-X's working directory: /Users/badlogic/workspaces/minifb
LOG: Logging init: beginning logging proper. This is the end of the early init logging
LOG: Logging: No logfile was given. All further logging will be discarded.
LOG: DOSBox-X version 0.84.1 (macOS SDL2)
LOG: macOS EXE path: dosbox-x
LOG: macOS Resource path: 
LOG: macOS: NSTouchBar support detected in system
LOG: Host keyboard layout is now us (US English)
LOG: Mapper keyboard layout is now us (US English)
LOG: SDL2 reports desktop display mode 2056 x 1329
LOG: The default output for the video system: surface
LOG: Configured windowposition: -
LOG: SDL: Current window pixel format: SDL_PIXELFORMAT_ARGB8888
LOG: Screen report: Method 'CoreGraphics' (2056.000 x 1329.000 pixels) at (0.000 x 0.000) (344.702 x 222.816 mm) (13.571 x 8.772 in) (151.500 x 151.500 DPI)
LOG: ISA BCLK: 8333333.333Hz (25000000/3)
LOG: monopal: green, 
LOG: Active save slot: 1 [Empty]
LOG: USING AVI+ZMBV
LOG: Max 3670016 sz 16384
LOG: Final 16384
LOG: MIDI:Opened device:coreaudio
LOG: Pentium CMPXCHG8B emulation is enabled
LOG: VOODOO LFB now at d0000000
LOG: Serial1: BASE 3f8h
LOG: Serial2: BASE 2f8h
LOG: Parallel1: BASE 378h
LOG: MPU-401 Registering I/O ports as if IBM PC MPU-401 at base 330h
LOG: Screen report: Method 'CoreGraphics' (2056.000 x 1329.000 pixels) at (0.000 x 0.000) (344.702 x 222.816 mm) (13.571 x 8.772 in) (151.500 x 151.500 DPI)
LOG: Allocated APM BIOS pm entry point at f000:ce20
LOG: Writing code to fce20
LOG: Writing code to fce40
LOG: ETHERNET: NE2000 Ethernet emulation backend selected: slirp
LOG: SLIRP: Slirp version: 4.7.0
LOG: SLIRP: Successfully initialized
LOG: NE2000: Base=0x300 irq=3
LOG: Screen report: Method 'CoreGraphics' (2056.000 x 1329.000 pixels) at (0.000 x 0.000) (344.702 x 222.816 mm) (13.571 x 8.772 in) (151.500 x 151.500 DPI)
LOG: ISA Plug & Play BIOS enabled
LOG: VGA ROM BIOS init callback
LOG: WARNING: No translation support (to host) for code page 0
LOG:          0 ERROR BIOS:Keyboard layout file auto not found
LOG:          0 ERROR BIOS:Keyboard layout file auto not found
LOG: XMS: 50 handles allocated for use by the DOS environment
LOG: EMS page frame at 0xe000-0xefff
LOG: COMMAND.COM env size:             720 bytes
LOG: COMMAND.COM environment block:    0x0701 sz=0x002d
LOG: COMMAND.COM main body (PSP):      0x072f sz=0x009a
LOG: COMMAND.COM stack:                0x0749
LOG: pixratio 1.350, dw false, dh false
LOG: Aspect ratio: 720 x 540  xToY=1.333 yToX=0.750
LOG: surface consider=720x400 final=720x400
LOG: Screen report: Method 'CoreGraphics' (2056.000 x 1329.000 pixels) at (0.000 x 0.000) (344.702 x 222.816 mm) (13.571 x 8.772 in) (151.500 x 151.500 DPI)
LOG: SHELL:Redirect output to nul
LOG: DOSBox-X has switched to max cycles, because of the setting: cycles=auto.
If the game runs too fast, try a fixed cycles amount in DOSBox-X's options.


### Additional information

_No response_

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

- [X] I have searched and didn't find any similar bug report.

### Code of Conduct & Contributing Guidelines

- [X] I agree to follow the code of conduct and the contributing guidelines.
@badlogic badlogic added the bug label Dec 19, 2022
@emendelson
Copy link
Contributor

emendelson commented Dec 19, 2022

I can confirm this with current code, in both the SDL1 and SDL2 builds. I get the correct result in an Apple Silicon build I made on 1 April 2022, but the wrong result in an Apple Silicon build I made on 3 September 2022. I can't narrow it down beyond that, but the regression clearly happened in April through July of this year.

@mariobrx
Copy link

Did you try to put fpu=false in the CPU section of conf file ? I also had calculation issues on RaspiOS 64bit in VisualBasic for DOS (see https://github.com/joncampbell123/dosbox-x/issues/3872)

@emendelson
Copy link
Contributor

Yes, fpu=false has no effect on this bug.

@joncampbell123
Copy link
Owner

If you can compile from source, try the latest commit. Some floating point fixes have been made.

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

No branches or pull requests

5 participants