OpCode32SimdMemMult.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. namespace ARMeilleure.Decoders
  2. {
  3. class OpCode32SimdMemMult : OpCode32
  4. {
  5. public int Rn { get; }
  6. public int Vd { get; }
  7. public int RegisterRange { get; }
  8. public int Offset { get; }
  9. public int PostOffset { get; }
  10. public bool IsLoad { get; }
  11. public bool DoubleWidth { get; }
  12. public bool Add { get; }
  13. public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdMemMult(inst, address, opCode, false);
  14. public static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdMemMult(inst, address, opCode, true);
  15. public OpCode32SimdMemMult(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode)
  16. {
  17. IsThumb = isThumb;
  18. Rn = (opCode >> 16) & 0xf;
  19. bool isLoad = (opCode & (1 << 20)) != 0;
  20. bool w = (opCode & (1 << 21)) != 0;
  21. bool u = (opCode & (1 << 23)) != 0;
  22. bool p = (opCode & (1 << 24)) != 0;
  23. if (p == u && w)
  24. {
  25. Instruction = InstDescriptor.Undefined;
  26. return;
  27. }
  28. DoubleWidth = (opCode & (1 << 8)) != 0;
  29. if (!DoubleWidth)
  30. {
  31. Vd = ((opCode >> 22) & 0x1) | ((opCode >> 11) & 0x1e);
  32. }
  33. else
  34. {
  35. Vd = ((opCode >> 18) & 0x10) | ((opCode >> 12) & 0xf);
  36. }
  37. Add = u;
  38. RegisterRange = opCode & 0xff;
  39. int regsSize = RegisterRange * 4; // Double mode is still measured in single register size.
  40. if (!u)
  41. {
  42. Offset -= regsSize;
  43. }
  44. if (w)
  45. {
  46. PostOffset = u ? regsSize : -regsSize;
  47. }
  48. else
  49. {
  50. PostOffset = 0;
  51. }
  52. IsLoad = isLoad;
  53. int regs = DoubleWidth ? RegisterRange / 2 : RegisterRange;
  54. if (RegisterRange == 0 || RegisterRange > 32 || Vd + regs > 32)
  55. {
  56. Instruction = InstDescriptor.Undefined;
  57. }
  58. }
  59. }
  60. }