From 6a47370219ced8dc63a5c81b20159924d1c1f885 Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Wed, 25 Mar 2026 21:48:37 -0700 Subject: [PATCH] [a64] Fix `ATOMIC_EXCHANGE` `swp` operand order `swp` is weird and actually writes the first operand into the memory address into the third operand, _and puts the old value into the second operand_. --- src/xenia/cpu/backend/a64/a64_seq_memory.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xenia/cpu/backend/a64/a64_seq_memory.cc b/src/xenia/cpu/backend/a64/a64_seq_memory.cc index e5424bd99..bf7600363 100644 --- a/src/xenia/cpu/backend/a64/a64_seq_memory.cc +++ b/src/xenia/cpu/backend/a64/a64_seq_memory.cc @@ -909,7 +909,7 @@ struct ATOMIC_EXCHANGE_I8 } if (e.IsFeatureEnabled(kA64EmitLSE)) { - e.swpalb(i.dest, e.w0, ptr(e.x4)); + e.swpalb(e.w0, i.dest, ptr(e.x4)); return; } @@ -938,7 +938,7 @@ struct ATOMIC_EXCHANGE_I16 } if (e.IsFeatureEnabled(kA64EmitLSE)) { - e.swpalh(i.dest, e.w0, ptr(e.x4)); + e.swpalh(e.w0, i.dest, ptr(e.x4)); return; } @@ -968,7 +968,7 @@ struct ATOMIC_EXCHANGE_I32 } if (e.IsFeatureEnabled(kA64EmitLSE)) { - e.swpal(i.dest, e.w0, ptr(e.x4)); + e.swpal(e.w0, i.dest, ptr(e.x4)); return; }