OpCodeT16IfThen.cs 966 B

123456789101112131415161718192021222324252627282930313233
  1. using System.Collections.Generic;
  2. namespace ARMeilleure.Decoders
  3. {
  4. class OpCodeT16IfThen : OpCodeT16
  5. {
  6. public Condition[] IfThenBlockConds { get; }
  7. public int IfThenBlockSize { get { return IfThenBlockConds.Length; } }
  8. public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCodeT16IfThen(inst, address, opCode);
  9. public OpCodeT16IfThen(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
  10. {
  11. List<Condition> conds = new();
  12. int cond = (opCode >> 4) & 0xf;
  13. int mask = opCode & 0xf;
  14. conds.Add((Condition)cond);
  15. while ((mask & 7) != 0)
  16. {
  17. int newLsb = (mask >> 3) & 1;
  18. cond = (cond & 0xe) | newLsb;
  19. mask <<= 1;
  20. conds.Add((Condition)cond);
  21. }
  22. IfThenBlockConds = conds.ToArray();
  23. }
  24. }
  25. }