Skip to content

Commit

Permalink
fix .map loading
Browse files Browse the repository at this point in the history
  • Loading branch information
x0r committed Sep 23, 2024
1 parent 4918464 commit 17c463f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions masm2c/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ def read_segments_map(self, file_name):
:param file_name: The name of the .map file
:return: A dictionary of segments and their values.
"""
content = read_whole_file(re.sub(r"\.lst$", ".map", file_name, flags=re.I)).splitlines()
map_file = re.sub(r"\.lst$", ".map", file_name, flags=re.I)
content = read_whole_file(map_file).splitlines()
DOSBOX_START_SEG = int(self.args.get("loadsegment"), 0)
strgenerator = iter(content)
segs = OrderedDict()
Expand All @@ -499,13 +500,18 @@ def read_segments_map(self, file_name):
break
# Reads text until the end of the block:
for line in strgenerator: # This keeps reading the file
if line.strip() == "Address Publics by Value":
break
if line.strip():
m = re.match(
r"^\s+(?P<start>[0-9A-F]{5,10})H [0-9A-F]{5,10}H [0-9A-F]{5,10}H (?P<segment>[_0-9A-Za-z]+)\s+[A-Z]+",
line)
segs[m["segment"]] = f"{int(m['start'], 16) // 16 + DOSBOX_START_SEG:04X}"
try:
if line.strip() == "Address Publics by Value":
break
if line.strip():
m = re.match(
r"^\s+(?P<start>[0-9A-F]{5,10})H [0-9A-F]{5,10}H [0-9A-F]{5,10}H (?P<segment>[_0-9A-Za-z]+)\s+",
line)
segs[m["segment"]] = f"{int(m['start'], 16) // 16 + DOSBOX_START_SEG:04X}"
except Exception as ex:
print("read_segments_map Exception", ex, map_file, line)
raise

logging.debug("Results of loading .map file: %s", segs)
return segs

Expand Down

0 comments on commit 17c463f

Please sign in to comment.