visitOperandsVar method

  1. @override
List<Operand> visitOperandsVar(
  1. int howMany,
  2. bool isVariable
)
override

Implementation

@override
List<Operand> visitOperandsVar(int howMany, bool isVariable) {
  final operands = <Operand>[];

  //load operand types
  int shiftStart = howMany > 4 ? 14 : 6;
  final os = howMany > 4 ? readw() : readb();

  int to;
  while (shiftStart > -2) {
    to = (os >> shiftStart) & 3; //shift and mask bottom 2 bits

    if (to == OperandType.omitted) {
      break;
    } else {
      operands.add(Operand(to));
      if (operands.length == howMany) break;
      shiftStart -= 2;
    }
  }

  //load values
  for (var o in operands) {
    o.rawValue = o.oType == OperandType.large ? readw() : readb();
  }

//    if (!isVariable && (operands.length != howMany)){
//      throw Exception('Operand count mismatch.  Expected ${howMany}, found ${operands.length}');
//    }

  return operands;
}