public ushort[] Parse(string[] lines)
{
try
{
this.machineCode.Clear();
this.labelReferences.Clear();
this.MessageOuput = string.Empty;
foreach (var line in lines)
{
LineCounter++;
var currentLine = line.Trim();
if (currentLine.Length < 1 || line[0] == ';')
{
continue;
}
currentLine = this.RemoveLineComments(line);
if (currentLine.Trim().Length < 1)
{
continue;
}
this.AssembleLine(currentLine);
}
this.SetLabelAddressReferences();
SetDataFieldLabelAddressReferences();
var count = 1;
foreach (var code in this.machineCode)
{
this.AddMessage(string.Format("{0:X4} ", code));
count++;
}
this.MessageOuput = this.MessageOuput.Substring(0, this.MessageOuput.Length - 2);
return this.machineCode.ToArray();
}
catch (Exception ex)
{
this.AddMessageLine(string.Format("Line {0}: {1}",LineCounter, ex.Message));
return null;
}
}