public void AddSection(X86AssemblySection section) { _labels.Add(section.Name); _sections.Add(section); if (section.Name == "_start") _nameDictionary.Add("_start", "_start"); else _nameDictionary.Add(section.Name, NextLabel()); }
public void AddSection(X86AssemblySection section) { _labels.Add(section.Name); _sections.Add(section); if (section.Name == "_start") { _nameDictionary.Add("_start", "_start"); } else { _nameDictionary.Add(section.Name, NextLabel()); } }
/// <summary> /// Requires to passes. First to register the labels, secondly for the actual code generation. /// </summary> private void ProcessCodeSession() { if (Eof) { return; } var section = new X86AssemblySection(); do { if (IsDataSectionComing()) { NextLine(); ProcessDataSection(); break; } if (Eof) { return; } MatchTokens(AsmTokens.Name); string name = CurrentLine[0].Value; if (IsInstruction(name)) { X86Instruction instruction = InstructionProcessor.ReadInstruction(CurrentLine); section.AddInstruction(instruction); continue; } if (CurrentLineSize > 1 && CurrentLine[1].Token == AsmTokens.Colon) { if (_assembly.NameExists(name)) { throw new LabelRedeclaredException(CurrentLine[0]); } if (!(section.DefaultLabel && section.InstructionCount == 0)) { _assembly.AddSection(section); } section = new X86AssemblySection(name); continue; } throw new UnknownInstructionException(name, CurrentLine[0].AsmLine); } while (NextLine()); _assembly.AddSection(section); }
/// <summary> /// Requires to passes. First to register the labels, secondly for the actual code generation. /// </summary> private void ProcessCodeSession() { if (Eof) return; var section = new X86AssemblySection(); do { if (IsDataSectionComing()) { NextLine(); ProcessDataSection(); break; } if (Eof) return; MatchTokens(AsmTokens.Name); string name = CurrentLine[0].Value; if (IsInstruction(name)) { X86Instruction instruction = InstructionProcessor.ReadInstruction(CurrentLine); section.AddInstruction(instruction); continue; } if (CurrentLineSize > 1 && CurrentLine[1].Token == AsmTokens.Colon) { if (_assembly.NameExists(name)) { throw new LabelRedeclaredException(CurrentLine[0]); } if (!(section.DefaultLabel && section.InstructionCount == 0)) _assembly.AddSection(section); section = new X86AssemblySection(name); continue; } throw new UnknownInstructionException(name, CurrentLine[0].AsmLine); } while (NextLine()); _assembly.AddSection(section); }