From 113c879d7ad51664df6172508e44377c54eb28d2 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Thu, 9 Nov 2023 23:16:17 +0100 Subject: Allow unaligned lock xchg with rex.w --- src/emu/x64runf0.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/emu/x64runf0.c b/src/emu/x64runf0.c index 9e6426f4..b9bc2c4c 100644 --- a/src/emu/x64runf0.c +++ b/src/emu/x64runf0.c @@ -946,7 +946,18 @@ uintptr_t RunF0(x64emu_t *emu, rex_t rex, uintptr_t addr) } } else { if(rex.w) { - GD->q[0] = native_lock_xchg_dd(ED, GD->q[0]); + if((uintptr_t)ED&7) { + // unaligned + do { + tmp64u = ED->q[0] & 0xffffffffffffff00LL; + tmp64u |= native_lock_read_b(ED); + + } while(native_lock_write_b(ED, GD->byte[0])); + ED->q[0] = GD->q[0]; + GD->q[0] = tmp64u; + } else { + GD->q[0] = native_lock_xchg_dd(ED, GD->q[0]); + } } else { GD->dword[0] = native_lock_xchg_d(ED, GD->dword[0]); } -- cgit 1.4.1