aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/Decoders/OpCode32.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ARMeilleure/Decoders/OpCode32.cs')
-rw-r--r--ARMeilleure/Decoders/OpCode32.cs16
1 files changed, 15 insertions, 1 deletions
diff --git a/ARMeilleure/Decoders/OpCode32.cs b/ARMeilleure/Decoders/OpCode32.cs
index 0d8ad1fd..92487c6e 100644
--- a/ARMeilleure/Decoders/OpCode32.cs
+++ b/ARMeilleure/Decoders/OpCode32.cs
@@ -13,11 +13,25 @@ namespace ARMeilleure.Decoders
Cond = (Condition)((uint)opCode >> 28);
}
+ public bool IsThumb()
+ {
+ return this is OpCodeT16 || this is OpCodeT32;
+ }
+
public uint GetPc()
{
// Due to backwards compatibility and legacy behavior of ARMv4 CPUs pipeline,
// the PC actually points 2 instructions ahead.
- return (uint)Address + (uint)OpCodeSizeInBytes * 2;
+ if (IsThumb())
+ {
+ // PC is ahead by 4 in thumb mode whether or not the current instruction
+ // is 16 or 32 bit.
+ return (uint)Address + 4u;
+ }
+ else
+ {
+ return (uint)Address + 8u;
+ }
}
}
} \ No newline at end of file