/// <summary>
        /// Gets a list of movement instructions from input
        /// </summary>
        /// <param name="instructions"></param>
        /// <returns></returns>
        public List <IInstruction> ParseInstructionSet(string instructions)
        {
            List <IInstruction> instructionsList   = null;
            IInstruction        instructionCreated = null;

            ParseMessages.Clear();

            if (string.IsNullOrEmpty(instructions))
            {
                ParseMessages.Add(Resources.ResourceFiles.ParseErrorMessages.InstructionsNumberIsNull);
                return(null);
            }

            else if (instructions.Length > 100)
            {
                ParseMessages.Add(Resources.ResourceFiles.ParseErrorMessages.InstructionsNumberGreaterThanMaximum);
                return(null);
            }

            else
            {
                instructionsList = new List <IInstruction>();

                for (int i = 0; i < instructions.Length; i++)
                {
                    instructionCreated = _instructionFactory.CreateInstruction(instructions[i]);
                    if (instructionCreated != null)
                    {
                        instructionsList.Add(instructionCreated);
                    }
                    else
                    {
                        ParseMessages.Add(Resources.ResourceFiles.ParseErrorMessages.InstructionsSetWithInvalidInstructionInput);
                        return(null);
                    }
                }
            }

            return(instructionsList);
        }
Beispiel #2
0
 public string Disassemble(uint hexInput)
 {
     return(((InstructionBase)_instructionFactory.CreateInstruction(hexInput)).ToString());
 }