diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2024-04-07 18:17:49 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-07 18:17:49 -0300 |
| commit | 808803d97a0c06809bf000687c252f960048fcf0 (patch) | |
| tree | ebf12fec1aa52a75512e894470902e8af1b2dae1 /src/ARMeilleure | |
| parent | ead9a251418bb2402ffa19ece089406b0678544e (diff) | |
CPU: Fix PC alignment for ADR thumb instruction (#6613)
* Fix PC alignment for ADR thumb instruction
* PPTC version bump
Diffstat (limited to 'src/ARMeilleure')
| -rw-r--r-- | src/ARMeilleure/Instructions/InstEmitAlu32.cs | 12 | ||||
| -rw-r--r-- | src/ARMeilleure/Translation/PTC/Ptc.cs | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/ARMeilleure/Instructions/InstEmitAlu32.cs b/src/ARMeilleure/Instructions/InstEmitAlu32.cs index 3a5e71bc..028ffbeb 100644 --- a/src/ARMeilleure/Instructions/InstEmitAlu32.cs +++ b/src/ARMeilleure/Instructions/InstEmitAlu32.cs @@ -19,6 +19,12 @@ namespace ARMeilleure.Instructions Operand n = GetAluN(context); Operand m = GetAluM(context, setCarry: false); + if (op.Rn == RegisterAlias.Aarch32Pc && op is OpCodeT32AluImm12) + { + // For ADR, PC is always 4 bytes aligned, even in Thumb mode. + n = context.BitwiseAnd(n, Const(~3u)); + } + Operand res = context.Add(n, m); if (ShouldSetFlags(context)) @@ -467,6 +473,12 @@ namespace ARMeilleure.Instructions Operand n = GetAluN(context); Operand m = GetAluM(context, setCarry: false); + if (op.Rn == RegisterAlias.Aarch32Pc && op is OpCodeT32AluImm12) + { + // For ADR, PC is always 4 bytes aligned, even in Thumb mode. + n = context.BitwiseAnd(n, Const(~3u)); + } + Operand res = context.Subtract(n, m); if (ShouldSetFlags(context)) diff --git a/src/ARMeilleure/Translation/PTC/Ptc.cs b/src/ARMeilleure/Translation/PTC/Ptc.cs index 6f6dfcad..f987284f 100644 --- a/src/ARMeilleure/Translation/PTC/Ptc.cs +++ b/src/ARMeilleure/Translation/PTC/Ptc.cs @@ -29,7 +29,7 @@ namespace ARMeilleure.Translation.PTC private const string OuterHeaderMagicString = "PTCohd\0\0"; private const string InnerHeaderMagicString = "PTCihd\0\0"; - private const uint InternalVersion = 5518; //! To be incremented manually for each change to the ARMeilleure project. + private const uint InternalVersion = 6613; //! To be incremented manually for each change to the ARMeilleure project. private const string ActualDir = "0"; private const string BackupDir = "1"; |
