OpCode32SimdShImm.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. namespace ARMeilleure.Decoders
  2. {
  3. class OpCode32SimdShImm : OpCode32Simd
  4. {
  5. public int Shift { get; }
  6. public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdShImm(inst, address, opCode, false);
  7. public new static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdShImm(inst, address, opCode, true);
  8. public OpCode32SimdShImm(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb)
  9. {
  10. int imm6 = (opCode >> 16) & 0x3f;
  11. int limm6 = ((opCode >> 1) & 0x40) | imm6;
  12. if ((limm6 & 0x40) == 0b1000000)
  13. {
  14. Size = 3;
  15. Shift = imm6;
  16. }
  17. else if ((limm6 & 0x60) == 0b0100000)
  18. {
  19. Size = 2;
  20. Shift = imm6 - 32;
  21. }
  22. else if ((limm6 & 0x70) == 0b0010000)
  23. {
  24. Size = 1;
  25. Shift = imm6 - 16;
  26. }
  27. else if ((limm6 & 0x78) == 0b0001000)
  28. {
  29. Size = 0;
  30. Shift = imm6 - 8;
  31. }
  32. else
  33. {
  34. Instruction = InstDescriptor.Undefined;
  35. }
  36. if (GetType() == typeof(OpCode32SimdShImm) && DecoderHelper.VectorArgumentsInvalid(Q, Vd, Vm))
  37. {
  38. Instruction = InstDescriptor.Undefined;
  39. }
  40. }
  41. }
  42. }