File tree 1 file changed +13
-6
lines changed
1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -29,8 +29,8 @@ HexFile::HexFile(const QString &fileName)
29
29
30
30
bool HexFile::read ()
31
31
{
32
- int lineCount = 1 ;
33
- int offsetAddr = 0 ;
32
+ int lineCount = 0 ;
33
+ uint offsetAddr = 0 ;
34
34
int dataCount;
35
35
int addr;
36
36
int type;
@@ -49,8 +49,15 @@ bool HexFile::read()
49
49
_prog.fill (static_cast <char >(0xFF ), 0x100 );
50
50
while (!stream.atEnd ())
51
51
{
52
+ lineCount++;
52
53
int index = 0 ;
53
54
QString line = stream.readLine ();
55
+ // :BBAAAATTHHHHHH.....HHHHCC
56
+
57
+ if (line.size () == 0 || line.startsWith (' ;' )) // comment or empty line
58
+ {
59
+ continue ;
60
+ }
54
61
55
62
if (line.size () < 11 )
56
63
{
@@ -83,7 +90,7 @@ bool HexFile::read()
83
90
}
84
91
index += 2 ;
85
92
86
- if (type == 0 )
93
+ if (type == 0 ) // data
87
94
{
88
95
if (offsetAddr + addr + dataCount > _prog.size ())
89
96
{
@@ -104,17 +111,17 @@ bool HexFile::read()
104
111
}
105
112
}
106
113
}
107
- else if (type == 4 )
114
+ else if (type == 4 ) // offset
108
115
{
109
- offsetAddr = line.mid (index , 4 ).toInt (&ok, 16 ) * 0x10000 ;
116
+ offsetAddr = line.mid (index , 4 ).toUInt (&ok, 16 ) * 0x10000 ;
110
117
if (!ok)
111
118
{
112
119
return false ;
113
120
}
114
121
index += 4 ;
115
122
// qDebug() << "offset" << QString::number(offsetAddr, 16);
116
123
}
117
- else if (type == 1 )
124
+ else if (type == 1 ) // end of file
118
125
{
119
126
break ;
120
127
}
You can’t perform that action at this time.
0 commit comments