OpCode32.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. namespace ARMeilleure.Decoders
  2. {
  3. class OpCode32 : OpCode
  4. {
  5. public Condition Cond { get; protected set; }
  6. public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32(inst, address, opCode);
  7. public OpCode32(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
  8. {
  9. RegisterSize = RegisterSize.Int32;
  10. Cond = (Condition)((uint)opCode >> 28);
  11. }
  12. public bool IsThumb { get; protected init; } = false;
  13. public uint GetPc()
  14. {
  15. // Due to backwards compatibility and legacy behavior of ARMv4 CPUs pipeline,
  16. // the PC actually points 2 instructions ahead.
  17. if (IsThumb)
  18. {
  19. // PC is ahead by 4 in thumb mode whether or not the current instruction
  20. // is 16 or 32 bit.
  21. return (uint)Address + 4u;
  22. }
  23. else
  24. {
  25. return (uint)Address + 8u;
  26. }
  27. }
  28. }
  29. }