public void AddOperands(OperandCollection operands, ReadOnlySpan <byte> bytes) { if (operands == null) { throw new ArgumentNullException(nameof(operands)); } var operandType1 = OperandType.Variable; operands.Add(operandType1, bytes[0]); var operandType2 = OperandType.Small; operands.Add(operandType2, bytes[1]); }
public Instruction(Machine machine) { if (machine == null) { throw new ArgumentNullException(nameof(machine)); } this.machine = machine; log = machine.Logger.ForContext <Instruction>(); Operands = new OperandCollection(machine); Operation = EmptyOperation; StoreResult = int.MinValue; Branch = BranchDescriptor.NullBranch; Text = ""; Size = 0; }
public void AddOperands(OperandCollection operands, ReadOnlySpan <byte> bytes) { if (operands == null) { throw new ArgumentNullException(nameof(operands)); } var type = Bits.FiveAndFour(bytes[0]); if (type == OperandType.Small || type == OperandType.Variable) { operands.Add(type, bytes[1]); } else if (type == OperandType.Large) { operands.Add(type, Bits.MakeWord(bytes.Slice(1, 2))); } }
public void AddOperands(OperandCollection operands, ReadOnlySpan <byte> bytes) { if (operands == null) { throw new ArgumentNullException(nameof(operands)); } var byteOffset = 1; var operandTypes = Bits.BreakIntoTwos(bytes[0]); foreach (var type in operandTypes) { switch (type) { case OperandType.Small: operands.Add(type, bytes[byteOffset]); byteOffset += 1; break; case OperandType.Variable: operands.Add(type, bytes[byteOffset]); byteOffset += 1; break; case OperandType.Large: operands.Add(type, Bits.MakeWord(bytes.Slice(byteOffset, 2))); byteOffset += 2; break; case OperandType.Ommitted: break; default: throw new InvalidOperationException($"Unknown operand type {type:X}"); } } }