Skip to content

Commit

Permalink
Merge pull request #5 from 86Box/master
Browse files Browse the repository at this point in the history
Rebase to master
  • Loading branch information
akmed772 authored Mar 5, 2025
2 parents 1a60f5a + 793a314 commit dc65ced
Show file tree
Hide file tree
Showing 15 changed files with 1,818 additions and 91 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,18 @@ option(RTMIDI "RtMidi"
option(FLUIDSYNTH "FluidSynth" ON)
option(MUNT "MUNT" ON)
option(VNC "VNC renderer" OFF)
option(NEW_DYNAREC "Use the PCem v15 (\"new\") dynamic recompiler" OFF)
option(MINITRACE "Enable Chrome tracing using the modified minitrace library" OFF)
option(GDBSTUB "Enable GDB stub server for debugging" OFF)
option(DEV_BRANCH "Development branch" OFF)
option(DISCORD "Discord Rich Presence support" ON)
option(DEBUGREGS486 "Enable debug register opeartion on 486+ CPUs" OFF)

if((ARCH STREQUAL "arm64") OR (ARCH STREQUAL "arm"))
set(NEW_DYNAREC ON)
else()
option(NEW_DYNAREC "Use the PCem v15 (\"new\") dynamic recompiler" OFF)
endif()

if(WIN32)
set(QT ON)
option(CPPTHREADS "C++11 threads" OFF)
Expand Down
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ elseif(APPLE AND NOT QT)
COMPONENT Runtime)
endif()


# Install the PDB file on Windows builds
if(MSVC)
# CMake fully supports PDB files on MSVC-compatible compilers
Expand Down
20 changes: 19 additions & 1 deletion src/codegen_new/codegen_backend_x86-64.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,19 @@ codegen_backend_init(void)
# endif
host_x86_CALL(block, (void *) x86gpf);
codegen_exit_rout = &codeblock[block_current].data[block_pos];
#ifdef _WIN64
host_x86_ADD64_REG_IMM(block, REG_RSP, 0x38);
#else
host_x86_ADD64_REG_IMM(block, REG_RSP, 0x48);
#endif
host_x86_POP(block, REG_R15);
host_x86_POP(block, REG_R14);
host_x86_POP(block, REG_R13);
host_x86_POP(block, REG_R12);
#ifdef _WIN64
host_x86_POP(block, REG_RDI);
host_x86_POP(block, REG_RSI);
#endif
host_x86_POP(block, REG_RBP);
host_x86_POP(block, REG_RDX);
host_x86_RET(block);
Expand All @@ -346,33 +352,45 @@ codegen_backend_prologue(codeblock_t *block)
block_pos = BLOCK_START; /*Entry code*/
host_x86_PUSH(block, REG_RBX);
host_x86_PUSH(block, REG_RBP);
#ifdef _WIN64
host_x86_PUSH(block, REG_RSI);
host_x86_PUSH(block, REG_RDI);
#endif
host_x86_PUSH(block, REG_R12);
host_x86_PUSH(block, REG_R13);
host_x86_PUSH(block, REG_R14);
host_x86_PUSH(block, REG_R15);
#ifdef _WIN64
host_x86_SUB64_REG_IMM(block, REG_RSP, 0x38);
#else
host_x86_SUB64_REG_IMM(block, REG_RSP, 0x48);
#endif
host_x86_MOV64_REG_IMM(block, REG_RBP, ((uintptr_t) &cpu_state) + 128);
if (block->flags & CODEBLOCK_HAS_FPU) {
host_x86_MOV32_REG_ABS(block, REG_EAX, &cpu_state.TOP);
host_x86_SUB32_REG_IMM(block, REG_EAX, block->TOP);
host_x86_MOV32_BASE_OFFSET_REG(block, REG_RSP, IREG_TOP_diff_stack_offset, REG_EAX);
}
if (block->flags & CODEBLOCK_NO_IMMEDIATES)
host_x86_MOV64_REG_IMM(block, REG_R12, (uintptr_t) ram);
host_x86_MOV64_REG_IMM(block, REG_R12, ((uintptr_t) ram) + 2147483648ULL);
}

void
codegen_backend_epilogue(codeblock_t *block)
{
#ifdef _WIN64
host_x86_ADD64_REG_IMM(block, REG_RSP, 0x38);
#else
host_x86_ADD64_REG_IMM(block, REG_RSP, 0x48);
#endif
host_x86_POP(block, REG_R15);
host_x86_POP(block, REG_R14);
host_x86_POP(block, REG_R13);
host_x86_POP(block, REG_R12);
#ifdef _WIN64
host_x86_POP(block, REG_RDI);
host_x86_POP(block, REG_RSI);
#endif
host_x86_POP(block, REG_RBP);
host_x86_POP(block, REG_RDX);
host_x86_RET(block);
Expand Down
2 changes: 1 addition & 1 deletion src/codegen_new/codegen_backend_x86-64_defs.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*RBP = cpu_state + 128
R12 = ram (if block->flags & CODEBLOCK_NO_IMMEDIATES)*/
R12 = ram + 2147483648 (if block->flags & CODEBLOCK_NO_IMMEDIATES)*/
#define REG_AX 0
#define REG_CX 1
#define REG_DX 2
Expand Down
Loading

0 comments on commit dc65ced

Please sign in to comment.