OpCode32SimdShImm.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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);
  7. public OpCode32SimdShImm(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
  8. {
  9. int imm6 = (opCode >> 16) & 0x3f;
  10. int limm6 = ((opCode >> 1) & 0x40) | imm6;
  11. if ((limm6 & 0x40) == 0b1000000)
  12. {
  13. Size = 3;
  14. Shift = imm6;
  15. }
  16. else if ((limm6 & 0x60) == 0b0100000)
  17. {
  18. Size = 2;
  19. Shift = imm6 - 32;
  20. }
  21. else if ((limm6 & 0x70) == 0b0010000)
  22. {
  23. Size = 1;
  24. Shift = imm6 - 16;
  25. }
  26. else if ((limm6 & 0x78) == 0b0001000)
  27. {
  28. Size = 0;
  29. Shift = imm6 - 8;
  30. }
  31. else
  32. {
  33. Instruction = InstDescriptor.Undefined;
  34. }
  35. if (GetType() == typeof(OpCode32SimdShImm) && DecoderHelper.VectorArgumentsInvalid(Q, Vd, Vm))
  36. {
  37. Instruction = InstDescriptor.Undefined;
  38. }
  39. }
  40. }
  41. }