public SourceFile(string path) { List <string> commands = new List <string>(); List <int> linesWithCommands = new List <int>(); int lineCounter = 0; string line; System.IO.StreamReader file = new System.IO.StreamReader(@path, CodePagesEncodingProvider.Instance.GetEncoding(1252)); while ((line = file.ReadLine()) != null) { //Check if line contains command, save it and remove it from the list string comment = ""; string[] lineCommentSplit = line.Split(";"); if (lineCommentSplit.Length > 1) { comment = lineCommentSplit[1]; line = lineCommentSplit[0]; } //Check if line contains label, save it string label; bool hasLabel = false; label = line.Substring(27).Split(" ")[0]; if (label != "") { hasLabel = true; } //Split line in substrings, seperated by " ", removing all duplicate white spaces string[] lineComponents = line.Split(" ", StringSplitOptions.RemoveEmptyEntries); //Check if line contains hexadecimal command bool hasCommand = false; if (!char.IsWhiteSpace(line, 0)) { commands.Add(lineComponents[1]); lineComponents = lineComponents.Skip(2).ToArray(); linesWithCommands.Add(lineCounter); hasCommand = true; } //Fill lineNumber and command variable if (lineComponents.Length > 0) { string lineNumber = lineComponents[0]; string command = ""; if (lineComponents.Length > 1) { command = string.Join(" ", lineComponents.Skip(hasLabel ? 2 : 1).ToArray()); } //Add line to list of SourceLines SourceLine sl = new SourceLine(lineNumber, label, command, comment, hasCommand); sourceLines.Add(sl); } lineCounter++; } file.Close(); this.linesWithCommands = linesWithCommands.ToArray(); //Write commands to Data store Data.SetWriteProgram(commands); }