From ce71f9144e1575c432bb009755f01466cd685fbf Mon Sep 17 00:00:00 2001 From: merry Date: Fri, 11 Feb 2022 20:51:03 +0000 Subject: [PATCH] InstEmitMemory32: Literal loads always have word-aligned PC (#3104) --- ARMeilleure/Instructions/InstEmitHelper.cs | 14 ++++++++++++++ ARMeilleure/Instructions/InstEmitMemory32.cs | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ARMeilleure/Instructions/InstEmitHelper.cs b/ARMeilleure/Instructions/InstEmitHelper.cs index 0479c380c2..d1b9de8422 100644 --- a/ARMeilleure/Instructions/InstEmitHelper.cs +++ b/ARMeilleure/Instructions/InstEmitHelper.cs @@ -47,6 +47,20 @@ namespace ARMeilleure.Instructions } } + public static Operand GetIntA32AlignedPC(ArmEmitterContext context, int regIndex) + { + if (regIndex == RegisterAlias.Aarch32Pc) + { + OpCode32 op = (OpCode32)context.CurrOp; + + return Const((int)(op.GetPc() & 0xfffffffc)); + } + else + { + return Register(GetRegisterAlias(context.Mode, regIndex), RegisterType.Integer, OperandType.I32); + } + } + public static Operand GetVecA32(int regIndex) { return Register(regIndex, RegisterType.Vector, OperandType.V128); diff --git a/ARMeilleure/Instructions/InstEmitMemory32.cs b/ARMeilleure/Instructions/InstEmitMemory32.cs index 64189134cf..af9eaf1aa0 100644 --- a/ARMeilleure/Instructions/InstEmitMemory32.cs +++ b/ARMeilleure/Instructions/InstEmitMemory32.cs @@ -153,7 +153,7 @@ namespace ARMeilleure.Instructions { OpCode32Mem op = (OpCode32Mem)context.CurrOp; - Operand n = context.Copy(GetIntA32(context, op.Rn)); + Operand n = context.Copy(GetIntA32AlignedPC(context, op.Rn)); Operand m = GetMemM(context, setCarry: false); Operand temp = default;