OpCodeAluImm.cs 957 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. namespace ARMeilleure.Decoders
  3. {
  4. class OpCodeAluImm : OpCodeAlu, IOpCodeAluImm
  5. {
  6. public long Immediate { get; private set; }
  7. public OpCodeAluImm(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
  8. {
  9. if (DataOp == DataOp.Arithmetic)
  10. {
  11. Immediate = (opCode >> 10) & 0xfff;
  12. int shift = (opCode >> 22) & 3;
  13. Immediate <<= shift * 12;
  14. }
  15. else if (DataOp == DataOp.Logical)
  16. {
  17. var bm = DecoderHelper.DecodeBitMask(opCode, true);
  18. if (bm.IsUndefined)
  19. {
  20. Instruction = InstDescriptor.Undefined;
  21. return;
  22. }
  23. Immediate = bm.WMask;
  24. }
  25. else
  26. {
  27. throw new ArgumentException(nameof(opCode));
  28. }
  29. }
  30. }
  31. }