mirror of
https://github.com/izzy2lost/Diddy-Kong-Racing.git
synced 2026-06-19 01:16:26 -07:00
Added glabels with upper/lower parts used <= 15 instructions apart.
This commit is contained in:
@@ -2,13 +2,17 @@ import re
|
||||
|
||||
from file_util import FileUtil
|
||||
|
||||
# Maximum number of lines between a glabel's upper/lower usage to look for.
|
||||
MAX_LINE_DIFF = 10
|
||||
|
||||
LINE_START_REGEX = r'\n(/\* ([0-9A-F]{6}) [0-9A-F]{8} [0-9A-F]{8} \*/\s+|\.L80[0-9A-F]{6}:)?'
|
||||
REG_REGEX = r'(\$(at|v[0-1]|a[0-3]|t[0-9]|s[0-7]|f[0-9]{1,2}|k[01]|gp|sp|fp|ra|zero))'
|
||||
GLABEL_UPPER_REGEX = '(' + LINE_START_REGEX + r'lui\s+' + REG_REGEX + r',\s+(0x80[0-9a-f]{2}))'
|
||||
GLABEL_LOWER_LS_REGEX = r'[sl][bhwd](u|c1)?\s+' + REG_REGEX + r',\s+(-?0x[0-9a-f]{3,4})\(\4\)'
|
||||
GLABEL_LOWER_ADDU_REGEX = r'addiu\s+' + REG_REGEX + r',\s+\4,\s+(-?0x[0-9a-f]{3,4})'
|
||||
GLABEL_LOWER_REGEX = LINE_START_REGEX + '(' + GLABEL_LOWER_LS_REGEX + '|' + GLABEL_LOWER_ADDU_REGEX + ')'
|
||||
GLABEL_REGEX = GLABEL_UPPER_REGEX + '(' + LINE_START_REGEX + '[^\n]*){0,10}' + GLABEL_LOWER_REGEX
|
||||
GLABEL_REGEX_STR = GLABEL_UPPER_REGEX + '(' + LINE_START_REGEX + '[^\n]*){0,' + str(MAX_LINE_DIFF) + '}' + GLABEL_LOWER_REGEX
|
||||
GLABEL_REGEX = re.compile(GLABEL_REGEX_STR)
|
||||
|
||||
UPPER_INSTR_REGEX_TMPL = r'(/\* %s[^\n#]*lui\s+)([^\n]*)'
|
||||
LOWER_INSTR_LS_REGEX_TMPL = r'(/\* %s[^\n#]*[ls][bhwd](u|c1)?\s+' + REG_REGEX + r',\s+)-?0x[0-9a-f]{3,4}([^\n]*)'
|
||||
@@ -22,7 +26,7 @@ def _find_glabels(asm):
|
||||
for file in FileUtil.get_filenames_from_directory_recursive('.', '.s'):
|
||||
#'''
|
||||
contents = FileUtil.get_text_from_file(file)
|
||||
matches = re.findall(GLABEL_REGEX, contents)
|
||||
matches = GLABEL_REGEX.findall(contents)
|
||||
for match in matches:
|
||||
reg = match[3]
|
||||
offsets = (match[2], match[10]) # ROM offsets of the lui and [sl][bhw]
|
||||
|
||||
Reference in New Issue
Block a user