/// <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); }
public X86Assembly GenerateAssembly() { _currentLine = 0; _assembly = new X86Assembly(); do { if (IsDataSectionComing()) { NextLine(); ProcessDataSection(); break; } if (IsCodeSectionComing()) { NextLine(); ProcessCodeSession(); break; } } while (NextLine()); if (_assembly.SectionCount == 0) { _assembly.AddSection(new X86AssemblySection()); } return(_assembly); }
public X86Assembly GenerateAssembly() { _currentLine = 0; _assembly = new X86Assembly(); do { if (IsDataSectionComing()) { NextLine(); ProcessDataSection(); break; } if (IsCodeSectionComing()) { NextLine(); ProcessCodeSession(); break; } } while (NextLine()); if (_assembly.SectionCount == 0) _assembly.AddSection(new X86AssemblySection()); return _assembly; }