I'm not as positive about the name of some undefined symbols anymore. Also slightly better stack pointer code

This commit is contained in:
Ryan Myers
2021-09-30 14:46:38 -04:00
parent ed87ea82f0
commit 7c7376bc7b
6 changed files with 24 additions and 27 deletions
+15 -18
View File
@@ -20,8 +20,6 @@ LOWER_INSTR_LS_REGEX_TMPL = r'(/\* %s[^\n#]*[ls][bhwd](u|c1)?\s+' + REG_REGEX +
LOWER_INSTR_ADDU_REGEX_TMPL = r'(/\* %s[^\n#]*addiu\s+' + REG_REGEX + r',\s+' + REG_REGEX + r',\s+)-?0x[0-9a-f]{3,4}'
LOWER_INSTR_ADDU_SAME_REGEX_TMPL = r'(/\* %s[^\n#]*)(addiu\s+' + REG_REGEX + r',\s+\3,\s+-?0x[0-9a-f]{3,4})'
IGNORE_GLABELS = ['D_800E389E', 'D_801264A1', 'D_800E1B84']
def _find_glabels(asm):
glabels = []
for file in FileUtil.get_filenames_from_directory_recursive('.', '.s'):
@@ -38,22 +36,21 @@ def _find_glabels(asm):
if glabel_lower & 0x8000:
glabel_upper -= 1
glabel = 'D_%08X' % (glabel_upper << 16 | glabel_lower)
if glabel not in IGNORE_GLABELS:
glabels.append((glabel, *offsets))
# replace upper instruction
contents = re.sub(UPPER_INSTR_REGEX_TMPL % offsets[0],
r'\1%s, %%hi(%s) # \2' % (reg, glabel),
contents)
# replace lower instruction
contents = re.sub(LOWER_INSTR_LS_REGEX_TMPL % offsets[1],
r'\1%%lo(%s)\5' % glabel,
contents)
contents = re.sub(LOWER_INSTR_ADDU_SAME_REGEX_TMPL % offsets[1],
r'\1addiu \3, %%lo(%s) # \2' % glabel,
contents)
contents = re.sub(LOWER_INSTR_ADDU_REGEX_TMPL % offsets[1],
r'\1%%lo(%s)' % glabel,
contents)
glabels.append((glabel, *offsets))
# replace upper instruction
contents = re.sub(UPPER_INSTR_REGEX_TMPL % offsets[0],
r'\1%s, %%hi(%s) # \2' % (reg, glabel),
contents)
# replace lower instruction
contents = re.sub(LOWER_INSTR_LS_REGEX_TMPL % offsets[1],
r'\1%%lo(%s)\5' % glabel,
contents)
contents = re.sub(LOWER_INSTR_ADDU_SAME_REGEX_TMPL % offsets[1],
r'\1addiu \3, %%lo(%s) # \2' % glabel,
contents)
contents = re.sub(LOWER_INSTR_ADDU_REGEX_TMPL % offsets[1],
r'\1%%lo(%s)' % glabel,
contents)
if len(matches):
FileUtil.write_text_to_file(file, contents)
return glabels