fix asmsplit

This commit is contained in:
Charlotte 🦝 Delenk 2022-10-14 08:23:50 +01:00
parent 313e5be3cc
commit 2f2f75c5b2
Signed by: darkkirb
GPG key ID: AB2BD8DAF2E37122

View file

@ -10,7 +10,6 @@ import sys
basedir = 'asm/' basedir = 'asm/'
macros = 'macros.inc' macros = 'macros.inc'
filename_counter = 0
filenames = {} filenames = {}
lastfile = None lastfile = None
@ -20,8 +19,7 @@ with open(sys.argv[1]) as mapfile:
if match and match.group(2) != lastfile: if match and match.group(2) != lastfile:
lastfile = match.group(2) lastfile = match.group(2)
addr = int(match.group(1), 16) addr = int(match.group(1), 16)
fname = basedir + '/'.join(map(lambda s: os.path.splitext(s)[0], match.group(2).strip().split(' '))) + f"_{filename_counter}" + '.s' fname = basedir + '/'.join(map(lambda s: os.path.splitext(s)[0], match.group(2).strip().split(' '))) + f"_{hex(addr)[2:]}" + '.s'
filename_counter += 1
filenames[addr] = fname filenames[addr] = fname
curfile = open(macros, 'w') curfile = open(macros, 'w')
@ -33,7 +31,10 @@ while asmline := remainder or sys.stdin.readline():
remainder = None remainder = None
trim = asmline.strip() trim = asmline.strip()
if trim.startswith('.section'): if trim.startswith('.section'):
curaddr = int(trim[-23:-13], 0) ex = trim.split("#", 1)
comment = ex[1]
ex = comment.split(" ")
curaddr = int(ex[1], 0)
section = asmline section = asmline
curfile.close() curfile.close()
else: else: