コード例 #1
0
ファイル: DebugInfo.cs プロジェクト: Rohansi/Programe
        /// <summary>
        /// Load DebugInfo from a file.
        /// </summary>
        public static DebugInfo Load(string filename)
        {
            var db = new DebugInfo();

            using (var file = File.Open(filename, FileMode.Open, FileAccess.Read))
            using (var reader = new BinaryReader(file))
            {
                if (reader.ReadInt32() != Header)
                    throw new Exception("Bad header");

                var lineAddressCount = reader.ReadInt32();
                for (var i = 0; i < lineAddressCount; i++)
                {
                    var line = reader.ReadInt32();
                    var address = reader.ReadInt32();
                    db.lineAddresses.Add(new LineAddress(line, address));
                }

                var symbolCount = reader.ReadInt32();
                for (var i = 0; i < symbolCount; i++)
                {
                    var name = reader.ReadString();
                    var address = reader.ReadInt32();
                    db.symbols.Add(new Symbol(name, address));
                }
            }

            return db;
        }
コード例 #2
0
ファイル: Assembler.cs プロジェクト: Rohansi/Programe
        public Assembler(string sourceText)
        {
            source = sourceText;

            instructions = new List<AssemblerInstruction>();
            labels = new Dictionary<string, Label>();
            Debug = new DebugInfo();
        }