OpCodeT32BImm24.cs 1017 B

1234567891011121314151617181920212223242526272829303132333435
  1. using ARMeilleure.Instructions;
  2. namespace ARMeilleure.Decoders
  3. {
  4. class OpCodeT32BImm24 : OpCodeT32, IOpCode32BImm
  5. {
  6. public long Immediate { get; }
  7. public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCodeT32BImm24(inst, address, opCode);
  8. public OpCodeT32BImm24(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
  9. {
  10. uint pc = GetPc();
  11. if (inst.Name == InstName.Blx)
  12. {
  13. pc &= ~3u;
  14. }
  15. int imm11 = (opCode >> 0) & 0x7ff;
  16. int j2 = (opCode >> 11) & 1;
  17. int j1 = (opCode >> 13) & 1;
  18. int imm10 = (opCode >> 16) & 0x3ff;
  19. int s = (opCode >> 26) & 1;
  20. int i1 = j1 ^ s ^ 1;
  21. int i2 = j2 ^ s ^ 1;
  22. int imm32 = imm11 | (imm10 << 11) | (i2 << 21) | (i1 << 22) | (s << 23);
  23. imm32 = (imm32 << 8) >> 7;
  24. Immediate = pc + imm32;
  25. }
  26. }
  27. }