Skip to content

Commit 576c216

Browse files
committedNov 23, 2023
[editor:hexfile] Fixed HEX parser comment and emty line, fixed unsigned offset
1 parent 495954d commit 576c216

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed
 

‎src/editor/hexfile.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ HexFile::HexFile(const QString &fileName)
2929

3030
bool HexFile::read()
3131
{
32-
int lineCount = 1;
33-
int offsetAddr = 0;
32+
int lineCount = 0;
33+
uint offsetAddr = 0;
3434
int dataCount;
3535
int addr;
3636
int type;
@@ -49,8 +49,15 @@ bool HexFile::read()
4949
_prog.fill(static_cast<char>(0xFF), 0x100);
5050
while (!stream.atEnd())
5151
{
52+
lineCount++;
5253
int index = 0;
5354
QString line = stream.readLine();
55+
// :BBAAAATTHHHHHH.....HHHHCC
56+
57+
if (line.size() == 0 || line.startsWith(';')) // comment or empty line
58+
{
59+
continue;
60+
}
5461

5562
if (line.size() < 11)
5663
{
@@ -83,7 +90,7 @@ bool HexFile::read()
8390
}
8491
index += 2;
8592

86-
if (type == 0)
93+
if (type == 0) // data
8794
{
8895
if (offsetAddr + addr + dataCount > _prog.size())
8996
{
@@ -104,17 +111,17 @@ bool HexFile::read()
104111
}
105112
}
106113
}
107-
else if (type == 4)
114+
else if (type == 4) // offset
108115
{
109-
offsetAddr = line.mid(index, 4).toInt(&ok, 16) * 0x10000;
116+
offsetAddr = line.mid(index, 4).toUInt(&ok, 16) * 0x10000;
110117
if (!ok)
111118
{
112119
return false;
113120
}
114121
index += 4;
115122
// qDebug() << "offset" << QString::number(offsetAddr, 16);
116123
}
117-
else if (type == 1)
124+
else if (type == 1) // end of file
118125
{
119126
break;
120127
}

0 commit comments

Comments
 (0)