public EncodeLine[] PreprocessLines(string[] lines, uint pc) { ASMProcessEquivalencesResult processEquivalencesResult = ASMEquivalenceHelper.ProcessEquivalences(lines); if (processEquivalencesResult.ErrorCode > 0) { _errorTextBuilder.Append(processEquivalencesResult.ErrorMessage); } else { lines = processEquivalencesResult.Lines; } EncodeLine[] encodeLines = TranslatePseudo(lines, pc, true); ASMFindLabelsResult findLabelsResult = ValueHelper.LabelHelper.FindLabels(lines, encodeLines, pc); if (findLabelsResult.ErrorCode > 0) { _errorTextBuilder.Append(findLabelsResult.ErrorMessage); } encodeLines = TranslatePseudo(lines, pc); if (encodeLines == null) { encodeLines = new List <EncodeLine>().ToArray(); } return(encodeLines); }
public ASMFindLabelsResult FindLabels(string[] lines, EncodeLine[] encodeLines, uint pc) { ASMFindLabelsResult result = new ASMFindLabelsResult(); result.ErrorCode = 0; _errorTextBuilder.Length = 0; //LabelDict.Clear(); ClearLabelDict(); //int pc = ProcessPC(0, txt_StartPC.Text); int lineIndex = 0; int encodeLineIndex = 0; foreach (string line in lines) { if (string.IsNullOrEmpty(line)) { continue; } string processLine = ASMStringHelper.RemoveLeadingBracketBlock(line); processLine = ASMStringHelper.RemoveLeadingSpaces(processLine); processLine = ASMStringHelper.RemoveComment(processLine).ToLower(); string[] parts = ASMStringHelper.SplitLine(processLine); //pc = ASMPCHelper.ProcessOrg(pc, parts); ASMProcessPCResult processPCResult = ASMPCHelper.ProcessOrg(pc, parts, false); pc = processPCResult.PC; _errorTextBuilder.Append(processPCResult.ErrorMessage); ASMAddLabelResult processLabelResult = ProcessLabelStatement(parts); if (processLabelResult != null) { if (processLabelResult.ErrorCode > 0) { result.ErrorCode = 1; _errorTextBuilder.Append(processLabelResult.ErrorMessage); } } EncodingFormat encodingOrNull = FormatHelper.FindFormatByCommand(parts[0]); if (encodingOrNull != null) { EncodeLine eLine = new EncodeLine(); if ((encodeLines.Length > 0) && (encodeLineIndex < encodeLines.Length)) { eLine = encodeLines[encodeLineIndex]; } while ((eLine.LineIndex == lineIndex) && (encodeLineIndex < encodeLines.Length)) { pc += 4; encodeLineIndex++; if (encodeLineIndex < encodeLines.Length) { eLine = encodeLines[encodeLineIndex]; } } lineIndex++; } else { ASMAddLabelResult addLabelResult = AddLabel(pc, parts); if (addLabelResult.ErrorCode == 0) { pc = addLabelResult.PC; } else { _errorTextBuilder.Append(addLabelResult.ErrorMessage); result.ErrorCode = 1; } } } result.ErrorMessage = _errorTextBuilder.ToString(); return(result); }
public ASMFindLabelsResult FindLabels(string[] lines, EncodeLine[] encodeLines, uint pc) { ASMFindLabelsResult result = new ASMFindLabelsResult(); result.ErrorCode = 0; _errorTextBuilder.Length = 0; //LabelDict.Clear(); ClearLabelDict(); //int pc = ProcessPC(0, txt_StartPC.Text); int lineIndex = 0; int encodeLineIndex = 0; foreach (string line in lines) { if (string.IsNullOrEmpty(line)) continue; string processLine = ASMStringHelper.RemoveLeadingBracketBlock(line); processLine = ASMStringHelper.RemoveLeadingSpaces(processLine); processLine = ASMStringHelper.RemoveComment(processLine).ToLower(); string[] parts = ASMStringHelper.SplitLine(processLine); //pc = ASMPCHelper.ProcessOrg(pc, parts); ASMProcessPCResult processPCResult = ASMPCHelper.ProcessOrg(pc, parts, false); pc = processPCResult.PC; _errorTextBuilder.Append(processPCResult.ErrorMessage); ASMAddLabelResult processLabelResult = ProcessLabelStatement(parts); if (processLabelResult != null) { if (processLabelResult.ErrorCode > 0) { result.ErrorCode = 1; _errorTextBuilder.Append(processLabelResult.ErrorMessage); } } EncodingFormat encodingOrNull = FormatHelper.FindFormatByCommand(parts[0]); if (encodingOrNull != null) { EncodeLine eLine = new EncodeLine(); if (encodeLines.Length > 0) eLine = encodeLines[encodeLineIndex]; while ((eLine.LineIndex == lineIndex) && (encodeLineIndex < encodeLines.Length)) { pc += 4; encodeLineIndex++; if (encodeLineIndex < encodeLines.Length) eLine = encodeLines[encodeLineIndex]; } lineIndex++; } else { ASMAddLabelResult addLabelResult = AddLabel(pc, parts); if (addLabelResult.ErrorCode == 0) { pc = addLabelResult.PC; } else { _errorTextBuilder.Append(addLabelResult.ErrorMessage); result.ErrorCode = 1; } } } result.ErrorMessage = _errorTextBuilder.ToString(); return result; }