Ejemplo n.º 1
0
        public bool parse(string a_t7File)
        {
            byte[] signature = new byte[8] {0xFF, 0x60, 0x4C, 0xDF, 0x3C, 0x0C, 0x4E, 0x75 };
            uint offset;
            int i = 0;
            UInt16 nrOfSymbols;
            if (!File.Exists(a_t7File))
                return false;
            FileStream fs = new FileStream(a_t7File, FileMode.Open, FileAccess.Read);
            fs.Position = 0;

            while(i < signature.Length)
            {
                if (fs.ReadByte() == signature[i])
                {
                    i++;
                    continue;
                }
                if (fs.Position > 0x60000)
                    return false;
                i = 0;
            }
            offset = (uint)fs.Position;
            nrOfSymbols = readUint16(fs);
            offset = (uint)nrOfSymbols * 14 + offset;
            long position = fs.Position;
            for (i = 0; i < nrOfSymbols; i++)
            {
                fs.Position = position;
                UInt32 addr = readUint32(fs);
                UInt16 dataLength = readUint16(fs);
                Symbol symbol = new Symbol(dataLength);
                if (addr < 0x70000)
                    symbol.setROMAddress(addr);
                else
                    symbol.setRAMAddress(addr);
                symbol.setDataLength(dataLength);
                symbol.setSymbolType(readUint32(fs));
                symbol.setSymbolNameAddress(readUint32(fs));
                position = fs.Position;

                fs.Position = (long)symbol.getSymbolNameAddress();
                symbol.setSymbolName(readString(fs));

                if (symbol.getROMAddress() != 0)
                {
                    fs.Position = (long)symbol.getROMAddress();
                    byte[] data = new byte[symbol.getDataLength()];
                    fs.Read(data, 0, data.Length);
                    symbol.setROMValue(data);
                }
                m_symbolList.Add(symbol);
            }

            return true;
        }
Ejemplo n.º 2
0
        public bool parse(string a_t7File)
        {
            m_nrOfSymbols = 0;
            if (!File.Exists(a_t7File))
                return false;
            FileStream fs = new FileStream(a_t7File, FileMode.Open, FileAccess.Read);
            fs.Position = 0;

            StreamReader reader = new StreamReader( a_t7File );
            string content = reader.ReadToEnd();
            reader.Close();
            UInt32 blockNr = 0;
            UInt32 symbolNr = 0;
            tableContainsStrings = false;
            if (!Regex.IsMatch(content, "BlockType"))
                tableContainsStrings = false;
            else
                tableContainsStrings = true;
            while (fs.Position < fs.Length)
            {
                UInt32 address;
                Symbol symbol = new Symbol();
                fs.ReadByte();
                address = readUint32(fs, 3);
                if (address < 0xF00000)
                    symbol.setROMAddress(address);
                else
                    symbol.setRAMAddress(address);
                symbol.setDataLength(readUint32(fs, 2));
                symbol.setSymbolType(readUint32(fs, 1));
                if (tableContainsStrings)
                {
                    symbol.setSymbolName(readString(fs));
                }
                else
                {
                    if (symbol.getRAMAddress() == symbol.getROMAddress())
                        symbol.setSymbolName("Block nr " + blockNr++);
                    else
                        symbol.setSymbolName("Symbol nr " + symbolNr++);
                }
                m_symbolList.Add(symbol);
                //logger.Debug("Added: " + symbol.getSymbolName());
                m_nrOfSymbols++;
            }

            return true;
        }
Ejemplo n.º 3
0
        public bool parse(string a_t7File)
        {
            byte[] signature = new byte[8] {
                0xFF, 0x60, 0x4C, 0xDF, 0x3C, 0x0C, 0x4E, 0x75
            };
            uint   offset;
            int    i = 0;
            UInt16 nrOfSymbols;

            if (!File.Exists(a_t7File))
            {
                return(false);
            }
            FileStream fs = new FileStream(a_t7File, FileMode.Open, FileAccess.Read);

            fs.Position = 0;

            while (i < signature.Length)
            {
                if (fs.ReadByte() == signature[i])
                {
                    i++;
                    continue;
                }
                if (fs.Position > 0x60000)
                {
                    return(false);
                }
                i = 0;
            }
            offset      = (uint)fs.Position;
            nrOfSymbols = readUint16(fs);
            offset      = (uint)nrOfSymbols * 14 + offset;
            long position = fs.Position;

            for (i = 0; i < nrOfSymbols; i++)
            {
                fs.Position = position;
                UInt32 addr       = readUint32(fs);
                UInt16 dataLength = readUint16(fs);
                Symbol symbol     = new Symbol(dataLength);
                if (addr < 0x70000)
                {
                    symbol.setROMAddress(addr);
                }
                else
                {
                    symbol.setRAMAddress(addr);
                }
                symbol.setDataLength(dataLength);
                symbol.setSymbolType(readUint32(fs));
                symbol.setSymbolNameAddress(readUint32(fs));
                position = fs.Position;

                fs.Position = (long)symbol.getSymbolNameAddress();
                symbol.setSymbolName(readString(fs));

                if (symbol.getROMAddress() != 0)
                {
                    fs.Position = (long)symbol.getROMAddress();
                    byte[] data = new byte[symbol.getDataLength()];
                    fs.Read(data, 0, data.Length);
                    symbol.setROMValue(data);
                }
                m_symbolList.Add(symbol);
            }


            return(true);
        }
Ejemplo n.º 4
0
        public bool parse(string a_t7File)
        {
            m_nrOfSymbols = 0;
            if (!File.Exists(a_t7File))
            {
                return(false);
            }
            FileStream fs = new FileStream(a_t7File, FileMode.Open, FileAccess.Read);

            fs.Position = 0;

            StreamReader reader  = new StreamReader(a_t7File);
            string       content = reader.ReadToEnd();

            reader.Close();
            UInt32 blockNr  = 0;
            UInt32 symbolNr = 0;

            tableContainsStrings = false;
            if (!Regex.IsMatch(content, "BlockType"))
            {
                tableContainsStrings = false;
            }
            else
            {
                tableContainsStrings = true;
            }
            while (fs.Position < fs.Length)
            {
                UInt32 address;
                Symbol symbol = new Symbol();
                fs.ReadByte();
                address = readUint32(fs, 3);
                if (address < 0xF00000)
                {
                    symbol.setROMAddress(address);
                }
                else
                {
                    symbol.setRAMAddress(address);
                }
                symbol.setDataLength(readUint32(fs, 2));
                symbol.setSymbolType(readUint32(fs, 1));
                if (tableContainsStrings)
                {
                    symbol.setSymbolName(readString(fs));
                }
                else
                {
                    if (symbol.getRAMAddress() == symbol.getROMAddress())
                    {
                        symbol.setSymbolName("Block nr " + blockNr++);
                    }
                    else
                    {
                        symbol.setSymbolName("Symbol nr " + symbolNr++);
                    }
                }
                m_symbolList.Add(symbol);
                //logger.Debug("Added: " + symbol.getSymbolName());
                m_nrOfSymbols++;
            }

            return(true);
        }