OpCode32.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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()
  13. {
  14. return this is OpCodeT16 || this is OpCodeT32;
  15. }
  16. public uint GetPc()
  17. {
  18. // Due to backwards compatibility and legacy behavior of ARMv4 CPUs pipeline,
  19. // the PC actually points 2 instructions ahead.
  20. if (IsThumb())
  21. {
  22. // PC is ahead by 4 in thumb mode whether or not the current instruction
  23. // is 16 or 32 bit.
  24. return (uint)Address + 4u;
  25. }
  26. else
  27. {
  28. return (uint)Address + 8u;
  29. }
  30. }
  31. }
  32. }