Fixed 8-bit XCHG instruction on the 64-bit old recompiler when both source and destination are a high 8-bit register (AH, CH, BH, or DH), fixes the longstanding Chicago 58s bug.

This commit is contained in:
OBattler
2020-12-12 15:59:10 +01:00
parent 09bc3d6cd0
commit a55b9c6512
2 changed files with 18 additions and 29 deletions

View File

@@ -297,6 +297,13 @@ static inline void STORE_REG_TARGET_B_RELEASE(int host_reg, int guest_reg)
addbyte(0x44);
addbyte(0x89);
addbyte(0xc0 | ((host_reg & 3) << 3));
}
else if (host_reg & 3)
{
addbyte(0x66); /*MOV AX, host_reg*/
addbyte(0x89);
addbyte(0xc0 | ((host_reg & 3) << 3));
}
if (host_reg & 0x10)
{
addbyte(0x66); /*AND AX, 0xff00*/
@@ -310,20 +317,6 @@ static inline void STORE_REG_TARGET_B_RELEASE(int host_reg, int guest_reg)
addbyte(0xe0);
addbyte(0x08);
}
}
else
{
if (host_reg)
{
addbyte(0x66); /*MOV AX, host_reg*/
addbyte(0x89);
addbyte(0xc0 | ((host_reg & 3) << 3));
}
addbyte(0x66); /*SHL AX, 8*/
addbyte(0xc1);
addbyte(0xe0);
addbyte(0x08);
}
addbyte(0x66); /*AND dest_reg, 0x00ff*/
addbyte(0x41);
addbyte(0x81);

View File

@@ -44,9 +44,6 @@ OP_XCHG_EAX_(EBP)
static uint32_t ropXCHG_b(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
{
/* #ifdef __amd64__
return 0;
#else */
int src_reg, dst_reg, temp_reg;
if ((fetchdat & 0xc0) != 0xc0)
@@ -59,7 +56,6 @@ static uint32_t ropXCHG_b(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin
STORE_REG_TARGET_B_RELEASE(temp_reg, fetchdat & 7);
return op_pc + 1;
/* #endif */
}
static uint32_t ropXCHG_w(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc, codeblock_t *block)
{