From cb52d0b6ec0c49de4e546bb76c26a3683878191f Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Tue, 9 Mar 2021 14:37:59 +0100 Subject: [PATCH] x64: andn() needs BMI1 cpu feature Issue #198 --- core/hw/arm7/arm7_rec_x64.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/core/hw/arm7/arm7_rec_x64.cpp b/core/hw/arm7/arm7_rec_x64.cpp index d546b7130..86b5ed5a2 100644 --- a/core/hw/arm7/arm7_rec_x64.cpp +++ b/core/hw/arm7/arm7_rec_x64.cpp @@ -90,6 +90,7 @@ class Arm7Compiler : public Xbyak::CodeGenerator static const u32 C_FLAG = 1 << 29; static const u32 V_FLAG = 1 << 28; + Xbyak::util::Cpu cpu; Xbyak::Operand getOperand(const ArmOp::Operand& arg, Xbyak::Reg32 scratch_reg) { @@ -438,7 +439,25 @@ class Arm7Compiler : public Xbyak::CodeGenerator mov(eax, op.arg[1].getImmediate()); arg1 = eax; } - andn(rd, static_cast(arg1), arg0); + if (cpu.has(Cpu::tBMI1)) + andn(rd, static_cast(arg1), arg0); + else + { + if (rd == arg0) + { + if (arg1 != r9d) + mov(r9d, arg1); + not_(r9d); + and_(rd, r9d); + } + else + { + if (arg1 != rd) + mov(rd, static_cast(arg1)); + not_(rd); + and_(rd, arg0); + } + } save_v_flag = false; break;