From d2c9e706c8485cd9fdafd3174f30841eb06efcc1 Mon Sep 17 00:00:00 2001 From: Antonio Castelli Date: Fri, 28 May 2021 11:46:11 -0700 Subject: [PATCH] Added glabels whose upper/lower usage has label definitions inbetween. --- asm/non_matchings/unknown_003260/func_80002C00.s | 4 ++-- asm/non_matchings/unknown_07B870/func_8007C57C.s | 4 ++-- asm/non_matchings/unknown_080500/func_80094D28.s | 4 ++-- asm/non_matchings/unknown_09F8F0/func_800A01A0.s | 6 +++--- asm/non_matchings/unknown_09F8F0/func_800ACA20.s | 4 ++-- tools/python/find_glabels.py | 12 ++++++------ 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/asm/non_matchings/unknown_003260/func_80002C00.s b/asm/non_matchings/unknown_003260/func_80002C00.s index 92e7924a..eb4e0731 100644 --- a/asm/non_matchings/unknown_003260/func_80002C00.s +++ b/asm/non_matchings/unknown_003260/func_80002C00.s @@ -46,7 +46,7 @@ glabel func_80002C00 /* 0038AC 80002CAC 3C0B800E */ lui $t3, %hi(D_800DC688) # $t3, 0x800e /* 0038B0 80002CB0 00E3082B */ sltu $at, $a3, $v1 /* 0038B4 80002CB4 10200004 */ beqz $at, .L80002CC8 -/* 0038B8 80002CB8 3C048011 */ lui $a0, 0x8011 +/* 0038B8 80002CB8 3C048011 */ lui $a0, %hi(D_80115F98) # $a0, 0x8011 /* 0038BC 80002CBC A6030004 */ sh $v1, 4($s0) /* 0038C0 80002CC0 86070004 */ lh $a3, 4($s0) /* 0038C4 80002CC4 00000000 */ nop @@ -55,7 +55,7 @@ glabel func_80002C00 /* 0038CC 80002CCC 3C058012 */ lui $a1, %hi(D_80119634) # $a1, 0x8012 /* 0038D0 80002CD0 000B6080 */ sll $t4, $t3, 2 /* 0038D4 80002CD4 008C2021 */ addu $a0, $a0, $t4 -/* 0038D8 80002CD8 8C845F98 */ lw $a0, 0x5f98($a0) +/* 0038D8 80002CD8 8C845F98 */ lw $a0, %lo(D_80115F98)($a0) /* 0038DC 80002CDC 8FA60024 */ lw $a2, 0x24($sp) /* 0038E0 80002CE0 0C019525 */ jal alAudioFrame /* 0038E4 80002CE4 24A59634 */ addiu $a1, %lo(D_80119634) # addiu $a1, $a1, -0x69cc diff --git a/asm/non_matchings/unknown_07B870/func_8007C57C.s b/asm/non_matchings/unknown_07B870/func_8007C57C.s index 99f364f4..a40f4aeb 100644 --- a/asm/non_matchings/unknown_07B870/func_8007C57C.s +++ b/asm/non_matchings/unknown_07B870/func_8007C57C.s @@ -21,13 +21,13 @@ glabel func_8007C57C /* 07D1C4 8007C5C4 10200003 */ beqz $at, .L8007C5D4 /* 07D1C8 8007C5C8 00000000 */ nop /* 07D1CC 8007C5CC 04810003 */ bgez $a0, .L8007C5DC -/* 07D1D0 8007C5D0 3C098012 */ lui $t1, 0x8012 +/* 07D1D0 8007C5D0 3C098012 */ lui $t1, %hi(D_80126320) # $t1, 0x8012 .L8007C5D4: /* 07D1D4 8007C5D4 1000001E */ b .L8007C650 /* 07D1D8 8007C5D8 00001025 */ move $v0, $zero .L8007C5DC: /* 07D1DC 8007C5DC 01234821 */ addu $t1, $t1, $v1 -/* 07D1E0 8007C5E0 8D296320 */ lw $t1, 0x6320($t1) +/* 07D1E0 8007C5E0 8D296320 */ lw $t1, %lo(D_80126320)($t1) /* 07D1E4 8007C5E4 00045080 */ sll $t2, $a0, 2 /* 07D1E8 8007C5E8 3C058012 */ lui $a1, %hi(D_8012636C) # $a1, 0x8012 /* 07D1EC 8007C5EC 8CA5636C */ lw $a1, %lo(D_8012636C)($a1) diff --git a/asm/non_matchings/unknown_080500/func_80094D28.s b/asm/non_matchings/unknown_080500/func_80094D28.s index 9d77d78c..ea0e7827 100644 --- a/asm/non_matchings/unknown_080500/func_80094D28.s +++ b/asm/non_matchings/unknown_080500/func_80094D28.s @@ -344,7 +344,7 @@ glabel func_80094D28 .L80095220: /* 095E20 80095220 3C0D8012 */ lui $t5, %hi(D_80126C1C) # $t5, 0x8012 /* 095E24 80095224 8DAD6C1C */ lw $t5, %lo(D_80126C1C)($t5) -/* 095E28 80095228 3C108012 */ lui $s0, 0x8012 +/* 095E28 80095228 3C108012 */ lui $s0, %hi(D_80126C14) # $s0, 0x8012 /* 095E2C 8009522C 11A00005 */ beqz $t5, .L80095244 /* 095E30 80095230 00000000 */ nop /* 095E34 80095234 3C108012 */ lui $s0, %hi(D_80126C24) # $s0, 0x8012 @@ -352,7 +352,7 @@ glabel func_80094D28 /* 095E3C 8009523C 10000004 */ b .L80095250 /* 095E40 80095240 2A010005 */ slti $at, $s0, 5 .L80095244: -/* 095E44 80095244 8E106C14 */ lw $s0, 0x6c14($s0) +/* 095E44 80095244 8E106C14 */ lw $s0, %lo(D_80126C14)($s0) /* 095E48 80095248 00000000 */ nop .L8009524C: /* 095E4C 8009524C 2A010005 */ slti $at, $s0, 5 diff --git a/asm/non_matchings/unknown_09F8F0/func_800A01A0.s b/asm/non_matchings/unknown_09F8F0/func_800A01A0.s index d6e31d9e..b616f3cd 100644 --- a/asm/non_matchings/unknown_09F8F0/func_800A01A0.s +++ b/asm/non_matchings/unknown_09F8F0/func_800A01A0.s @@ -127,7 +127,7 @@ glabel func_800A01A0 /* 0A0F78 800A0378 1041008B */ beq $v0, $at, .L800A05A8 /* 0A0F7C 800A037C 3C0F8012 */ lui $t7, %hi(D_80126D0C) # $t7, 0x8012 /* 0A0F80 800A0380 8DEF6D0C */ lw $t7, %lo(D_80126D0C)($t7) -/* 0A0F84 800A0384 3C048012 */ lui $a0, 0x8012 +/* 0A0F84 800A0384 3C048012 */ lui $a0, %hi(D_80126D10) # $a0, 0x8012 /* 0A0F88 800A0388 15E0002F */ bnez $t7, .L800A0448 /* 0A0F8C 800A038C 00000000 */ nop /* 0A0F90 800A0390 3C048012 */ lui $a0, %hi(D_80126D10) # $a0, 0x8012 @@ -171,7 +171,7 @@ glabel func_800A01A0 /* 0A1024 800A0424 904F0000 */ lbu $t7, ($v0) /* 0A1028 800A0428 24190078 */ li $t9, 120 /* 0A102C 800A042C 11E00004 */ beqz $t7, .L800A0440 -/* 0A1030 800A0430 3C01800E */ lui $at, 0x800e +/* 0A1030 800A0430 3C01800E */ lui $at, %hi(D_800E27B8) # $at, 0x800e /* 0A1034 800A0434 3C01800E */ lui $at, %hi(D_800E27B8) # $at, 0x800e /* 0A1038 800A0438 10000034 */ b .L800A050C /* 0A103C 800A043C A03927B8 */ sb $t9, %lo(D_800E27B8)($at) @@ -179,7 +179,7 @@ glabel func_800A01A0 /* 0A1040 800A0440 10000032 */ b .L800A050C /* 0A1044 800A0444 A02027B8 */ sb $zero, %lo(D_800E27B8)($at) .L800A0448: -/* 0A1048 800A0448 8C846D10 */ lw $a0, 0x6d10($a0) +/* 0A1048 800A0448 8C846D10 */ lw $a0, %lo(D_80126D10)($a0) /* 0A104C 800A044C 0C01A955 */ jal func_8006A554 /* 0A1050 800A0450 00000000 */ nop /* 0A1054 800A0454 30480004 */ andi $t0, $v0, 4 diff --git a/asm/non_matchings/unknown_09F8F0/func_800ACA20.s b/asm/non_matchings/unknown_09F8F0/func_800ACA20.s index 757ec4e7..6b27c6b1 100644 --- a/asm/non_matchings/unknown_09F8F0/func_800ACA20.s +++ b/asm/non_matchings/unknown_09F8F0/func_800ACA20.s @@ -124,13 +124,13 @@ glabel func_800ACA20 /* 0AD804 800ACC04 00000000 */ nop .L800ACC08: /* 0AD808 800ACC08 16420005 */ bne $s2, $v0, .L800ACC20 -/* 0AD80C 800ACC0C 3C108012 */ lui $s0, 0x8012 +/* 0AD80C 800ACC0C 3C108012 */ lui $s0, %hi(D_80127C28) # $s0, 0x8012 /* 0AD810 800ACC10 3C108012 */ lui $s0, %hi(D_80127C24) # $s0, 0x8012 /* 0AD814 800ACC14 8E107C24 */ lw $s0, %lo(D_80127C24)($s0) /* 0AD818 800ACC18 10000003 */ b .L800ACC28 /* 0AD81C 800ACC1C 00000000 */ nop .L800ACC20: -/* 0AD820 800ACC20 8E107C28 */ lw $s0, 0x7c28($s0) +/* 0AD820 800ACC20 8E107C28 */ lw $s0, %lo(D_80127C28)($s0) /* 0AD824 800ACC24 00000000 */ nop .L800ACC28: /* 0AD828 800ACC28 12000058 */ beqz $s0, .L800ACD8C diff --git a/tools/python/find_glabels.py b/tools/python/find_glabels.py index 1703d6d9..df02dfc5 100644 --- a/tools/python/find_glabels.py +++ b/tools/python/find_glabels.py @@ -2,20 +2,20 @@ import re from file_util import FileUtil -LINE_START_REGEX = r'\n/\* ([0-9A-F]{6}) [0-9A-F]{8} [0-9A-F]{8} \*/\s+' +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]|k[0-1]|gp|sp|fp|ra))' GLABEL_UPPER_REGEX = '(' + LINE_START_REGEX + r'lui\s+' + REG_REGEX + r',\s+(0x80[0-9a-f]{2}))' -GLABEL_LOWER_REGEX = '(' + LINE_START_REGEX + r'l[bhw]\s+' + REG_REGEX + r',\s+(0x[0-9a-f]{4})\(\3\))' -GLABEL_REGEX = GLABEL_UPPER_REGEX + '(' + LINE_START_REGEX + '[^\n]*(?=\n)){0,10}' + GLABEL_LOWER_REGEX +GLABEL_LOWER_REGEX = '(' + LINE_START_REGEX + r'l[bhw]\s+' + REG_REGEX + r',\s+(0x[0-9a-f]{4})\(\4\))' +GLABEL_REGEX = GLABEL_UPPER_REGEX + '(' + LINE_START_REGEX + '[^\n]*){0,10}' + GLABEL_LOWER_REGEX def _find_glabels(asm): glabels = [] for file in FileUtil.get_filenames_from_directory_recursive('.', '.s'): matches = re.findall(GLABEL_REGEX, FileUtil.get_text_from_file(file)) for match in matches: - offsets = (match[1], match[8]) # ROM offsets of the lu and lw - glabel_upper = int(match[4], 16) # upper immediate of glabel - glabel_lower = int(match[11], 16) # lower immediate of the glabel + offsets = (match[2], match[11]) # ROM offsets of the lu and lw + glabel_upper = int(match[5], 16) # upper immediate of glabel + glabel_lower = int(match[14], 16) # lower immediate of the glabel if glabel_lower & 0x8000: glabel_upper -= 1 glabel = 'D_%08X' % (glabel_upper << 16 | glabel_lower)