public List <int> Run() { List <int> output = _program.ToList(); int currentInstructionAddress = 0; IExecutable instruction; do { instruction = _instructionFactory.Create( output, _opcodeParser.Opcode(output[currentInstructionAddress]), Parameters(output, currentInstructionAddress)); instruction.Execute(); currentInstructionAddress += instruction.ParametersCount + 1; }while (!instruction.Halt); return(output); }
public Instruction Resolve(BitArray rawInstruction) { if (_instructionFactory != null) { return(_instructionFactory.Create()); } foreach (var resolverConfig in _opSizes) { var sample = rawInstruction.CopySlice(_offset, (int)resolverConfig.Key); if (resolverConfig.Value.TryGetValue(sample.ToUnsignedInt(), out var resolver)) { var result = resolver.Resolve(rawInstruction); if (result != null) { return(result); } } } return(null); }