コード例 #1
0
        public ConsoleSimulation(string inputFileName, CommandInterpreter interpreter)
        {
            m_Terminal       = new ConsoleEmulator(interpreter);
            m_Logger         = new ConsoleLogger();
            m_TerminationMgr = new TerminationManager(inputFileName);

            var fileParserFac = new FileReaderFactory();
            ICompiledFileReader  fileParser = fileParserFac.GetFileParser(inputFileName);
            DisassembledFileBase file       = fileParser.ParseFile(inputFileName, m_Logger);

            m_Terminal.PrintString("Successfully loaded " + inputFileName +
                                   " (source file: " + file.SourceInformation.SourceFilePath + "; " + file.TotalFileSize + " bytes)\n");

            m_ExecCtx = new RuntimeProcess(file, m_Terminal);

            IEnumerable <InstructionData> programInstructions =
                DisassemblerServices.GenerateInstructionData(file.SymbolTable, file.TextSegment, file.SourceInformation);

            m_SrcMapping = new Dictionary <int, SourceLineInformation>();

            foreach (InstructionData instructionElem in programInstructions)
            {
                m_SrcMapping.Add(instructionElem.ProgramCounterLocation, new SourceLineInformation(instructionElem));
            }

            m_CmdTable = new CommandTable(m_SrcMapping, m_ExecCtx, m_Terminal, m_TerminationMgr);

            m_Terminal.AddAvailableCommands(m_CmdTable.AllCommands);
        }
コード例 #2
0
        public void GenerateOutputFile(string outputFileName)
        {
            IEnumerable <InstructionData> txtInstructions =
                DisassemblerServices.GenerateInstructionData(m_File.SymbolTable, m_File.TextSegment, m_File.SourceInformation);

            using (var writer = new StreamWriter(File.Open(outputFileName, FileMode.Create)))
            {
                GenerateDataSegment(writer, m_File.SymbolTable, m_File.DataSegment);
                OutputTextSegment(writer, txtInstructions);
                writer.WriteLine(".extern extern_data " + m_File.ExternSegmentSize);
            }
        }
コード例 #3
0
        public DisassembledFileViewModel(string fileName,
                                         DisassembledFileBase runtimeFile)
        {
            m_UnderlyingFile = runtimeFile;
            m_Instructions   = new BindingList <ProgramInstructionViewModel>();
            m_FilePath       = fileName;
            IEnumerable <InstructionData> programInstructions =
                DisassemblerServices.GenerateInstructionData(runtimeFile.SymbolTable, runtimeFile.TextSegment, runtimeFile.SourceInformation);

            foreach (InstructionData instructionElem in programInstructions)
            {
                m_Instructions.Add(new ProgramInstructionViewModel(instructionElem));
            }
        }