public bool parse(string[] lines) { TiTxtRecord tr = new TiTxtRecord(); foreach (string lin in lines) { string line = lin.Trim(); if (line.Length < 1) { continue; } if (tr.parse(line)) { if (TiTxtRecord.RecordTypeE.SecStrtAddr == tr.RecordType) { MemBlock mb = new MemBlock(); mb.StartAddr = tr.Address; mb.AddrSize = 16; Memblks.Add(mb); } else if (TiTxtRecord.RecordTypeE.EOF == tr.RecordType) { // end of file } else if (TiTxtRecord.RecordTypeE.Data == tr.RecordType) { MemBlock mb = Memblks [Memblks.Count - 1]; if (0 == this.BytesEachLine) { this.BytesEachLine = tr.Data.Length; } mb.AppendData(tr.Data); } else { } } } MemBlock.MergeMBs(this.Memblks); return(true); }
public bool parse(string[] lines) { SRecord sr = new SRecord(); foreach (string lin in lines) { string line = lin.Trim(); if (line.Length < 1) { continue; } if (sr.parse(line)) { switch (sr.RecordType) { case SRecord.RecordTypeE.S0: { this.HeadRec = new byte[sr.Data.Length]; sr.Data.CopyTo(this.HeadRec, 0); } break; case SRecord.RecordTypeE.S1: { this.SFileType = SFileTypeE.S19; this.DataRecordNum++; if (0 == Memblks.Count) { MemBlock mb = new MemBlock(); mb.AddrSize = 16; mb.StartAddr = sr.Address; mb.AppendData(sr.Data); Memblks.Add(mb); } else { MemBlock mb = Memblks [Memblks.Count - 1]; if (mb.NextAddress == sr.Address) { mb.AppendData(sr.Data); } else // create a new MemBlock { MemBlock mbn = new MemBlock(); mbn.AddrSize = 16; mbn.StartAddr = sr.Address; mbn.AppendData(sr.Data); Memblks.Add(mbn); } } } break; case SRecord.RecordTypeE.S2: { this.SFileType = SFileTypeE.S28; this.DataRecordNum++; if (0 == Memblks.Count) { MemBlock mb = new MemBlock(); mb.AddrSize = 24; mb.StartAddr = sr.Address; mb.AppendData(sr.Data); Memblks.Add(mb); } else { MemBlock mb = Memblks [Memblks.Count - 1]; if (mb.NextAddress == sr.Address) { mb.AppendData(sr.Data); } else // create a new MemBlock { MemBlock mbn = new MemBlock(); mbn.AddrSize = 24; mbn.StartAddr = sr.Address; mbn.AppendData(sr.Data); Memblks.Add(mbn); } } } break; case SRecord.RecordTypeE.S3: { this.SFileType = SFileTypeE.S37; this.DataRecordNum++; if (0 == Memblks.Count) { MemBlock mb = new MemBlock(); mb.AddrSize = 32; mb.StartAddr = sr.Address; mb.AppendData(sr.Data); Memblks.Add(mb); } else { MemBlock mb = Memblks [Memblks.Count - 1]; if (mb.NextAddress == sr.Address) { mb.AppendData(sr.Data); } else // create a new MemBlock { MemBlock mbn = new MemBlock(); mbn.AddrSize = 32; mbn.StartAddr = sr.Address; mbn.AppendData(sr.Data); Memblks.Add(mbn); } } } break; case SRecord.RecordTypeE.S4: { // not used now } break; case SRecord.RecordTypeE.S5: { // check record count ushort recCount = BitConverter.ToUInt16(sr.Data, 0); if (recCount != this.DataRecordNum) { // error happens } } break; case SRecord.RecordTypeE.S6: { // check record count uint recCount = BitConverter.ToUInt16(sr.Data, 1); recCount += (uint)(sr.Data [0] << 16); if (recCount != this.DataRecordNum) { // error happens } } break; case SRecord.RecordTypeE.S7: { // end of S37, nothing to do } break; case SRecord.RecordTypeE.S8: { // end of S28, nothing to do } break; case SRecord.RecordTypeE.S9: { // end of S19, nothing to do } break; default: { } break; } } } MemBlock.MergeMBs(this.Memblks); return(true); }
public bool parse(string[] lines) { HexRecord hr = new HexRecord(); foreach (string lin in lines) { string line = lin.Trim(); if (line.Length < 1) { continue; } if (hr.parse(line)) { switch (hr.RecordType) { case HexRecord.RecordTypeE.Data: { MemBlock mb = Memblks [Memblks.Count - 1]; if ((0 == mb.DataSize) && ((0xFFFF & (mb.StartAddr)) != hr.Address)) { mb.StartAddr += hr.Address; } else if (((0xFFFF & (mb.StartAddr)) + mb.NextAddress) != hr.Address) // check the address { } else { } mb.AppendData(hr.Data); } break; case HexRecord.RecordTypeE.EoF: { // End of file } break; case HexRecord.RecordTypeE.ExtSegAddr: { MemBlock mb = new MemBlock(); ushort usba = BitConverter.ToUInt16(hr.Data, 0); uint sba = (uint)usba; sba <<= 4; mb.AddrSize = 20; mb.StartAddr = sba; this.Memblks.Add(mb); } break; case HexRecord.RecordTypeE.StrtSegAddr: { this.CsIp = BitConverter.ToUInt32(hr.Data, 0); } break; case HexRecord.RecordTypeE.ExtLineAddr: { MemBlock mb = new MemBlock(); ushort ulba = BitConverter.ToUInt16(hr.Data, 0); uint lba = (uint)ulba; lba <<= 16; mb.AddrSize = 32; mb.StartAddr = lba; this.Memblks.Add(mb); } break; case HexRecord.RecordTypeE.StrtLineAddr: { this.EIP = BitConverter.ToUInt32(hr.Data, 0); } break; default: break; } } } MemBlock.MergeMBs(this.Memblks); return(true); }