mirror of
https://github.com/joncampbell123/dosbox-x.git
synced 2025-10-14 02:17:36 +08:00
Apologies to dyn_x86. Instead of depending on mere typecasting, actually mask and compare to determine whether &cpu_regs resides above 4GB address-wise so the correct x86_64 executable code is generated.
This commit is contained in:
@@ -281,7 +281,9 @@ static BlockReturn gen_runcodeInit(uint8_t *code) {
|
||||
opcode(15).Emit8Reg(0x50); // push r15
|
||||
opcode(14).Emit8Reg(0x50); // push r14
|
||||
// mov rbp, &cpu_regs
|
||||
if ((uint32_t)(Bitu)&cpu_regs == (Bitu)&cpu_regs) opcode(5).setimm((Bitu)&cpu_regs,4).Emit8Reg(0xB8);
|
||||
/* NTS: For VS2019, mere typecasting won't correctly detect whether the pointer is small enough to fit in 32 bits.
|
||||
We have to mask and compare. If the pointer is above 4GB and the wrong choice is made, dynamic core will crash. --J.C. */
|
||||
if ((((Bitu)&cpu_regs) && (Bitu)0xFFFFFFFFul) == (Bitu)&cpu_regs) opcode(5).setimm((Bitu)&cpu_regs,4).Emit8Reg(0xB8);
|
||||
else opcode(5).set64().setimm((Bitu)&cpu_regs,8).Emit8Reg(0xB8);
|
||||
opcode(13).Emit8Reg(0x50); // push r13
|
||||
opcode(12).Emit8Reg(0x50); // push r12
|
||||
|
@@ -77,7 +77,7 @@
|
||||
/* The type of cpu this target has */
|
||||
# define C_TARGETCPU X86_64
|
||||
/* Define to 1 to use x86 dynamic cpu core */
|
||||
# undef C_DYNAMIC_X86 /* Sorry, dyn_x86 is crashing in 64-bit builds under VS2019 */
|
||||
# define C_DYNAMIC_X86 1
|
||||
# define C_DYNREC 1
|
||||
#elif defined (_M_ARM64) || defined (_M_ARM) /* Microsoft C++ amd64, arm32 and arm64 */
|
||||
# undef C_TARGETCPU
|
||||
|
Reference in New Issue
Block a user