Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 2
0
        public Assembler(string sourceText)
        {
            source = sourceText;

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