We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f84119a commit 7c9a0ebCopy full SHA for 7c9a0eb
tools/hexfile/hexfile.py
100644
100755
@@ -27,7 +27,8 @@
27
28
def LoadHexFile(lines):
29
"""Loads a Hex file."""
30
-
+ base_address = None
31
+ offset = 0
32
data = []
33
for line_number, line in enumerate(lines):
34
line = line.strip()
@@ -55,11 +56,18 @@ def LoadHexFile(lines):
55
56
else:
57
break
58
elif bytes[3] == 0:
- address = bytes[1] << 8 | bytes[2]
59
+ address = offset << 16 | bytes[1] << 8 | bytes[2]
60
padding_size = address + bytes[0] - len(data)
61
if padding_size > 0:
62
data += [0] * padding_size
63
data[address:address + bytes[0]] = bytes[4:-1]
64
+ elif bytes[3] == 4:
65
+ address = bytes[4] << 8 | bytes[5]
66
+ if base_address is None:
67
+ base_address = address
68
69
+ else:
70
+ offset = address - base_address
71
return data
72
73
0 commit comments