div method

void div()

Implementation

void div() {
  //Debugger.verbose('${pcHex(-1)} [div]');

  final operands = mem.loadb(programCounter- 1) < 193
      ? visitOperandsLongForm()
      : visitOperandsVar(2, false);

  final resultTo = readb();

  assert(operands[1].value != 0);

  // final result = (toSigned(operands[0].value) / toSigned(operands[1].value)).toInt();
  final result = MathHelper.toSigned(operands[0].value!) ~/ MathHelper.toSigned(operands[1].value!);

  //Debugger.verbose('    >>> (div ${pc.toRadixString(16)}) ${operands[0].value}(${toSigned(operands[0].value)}) / ${operands[1].value}(${toSigned(operands[1].value)}) = $result');

  writeVariable(resultTo, result);
}