private CPUState _mul(Instruction instruction) { _newProgramCounter++; if (instruction.SecondRegister.HasValue) { _alu.Multiply(Registers[instruction.FirstRegister.Value], Registers[instruction.SecondRegister.Value]); Registers[instruction.FirstRegister.Value] = _alu.AluResult; return(new CPUState(Registers, instruction, _programCounter)); } else if (instruction.FirstConstant.HasValue) { _alu.Multiply(Registers[instruction.FirstRegister.Value], instruction.FirstConstant.Value); Registers[instruction.FirstRegister.Value] = _alu.AluResult; return(new CPUState(Registers, instruction, _programCounter)); } else { throw new InvalidOperationException("No corresponding number of operands given."); } }