mirror of https://github.com/zeldaret/mm.git
Floats and Strings in asm (#82)
This commit is contained in:
parent
a5c039f2ee
commit
012e3c21ae
2
Makefile
2
Makefile
|
|
@ -207,7 +207,7 @@ build/baserom/%: baserom/%
|
|||
# FIXME: The process of splitting rodata changes the assembly files, so we must avoid making .o files for them until that is done.
|
||||
# The simplest way to do that is to give them an order dependency on .c files' .o files
|
||||
build/asm/%.o: asm/%.asm | $(C_O_FILES)
|
||||
$(AS) $(ASFLAGS) $^ -o $@
|
||||
iconv --from UTF-8 --to EUC-JP $^ | $(AS) $(ASFLAGS) -o $@
|
||||
|
||||
build/src/overlays/%.o: src/overlays/%.c
|
||||
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
|
||||
|
|
|
|||
|
|
@ -545,6 +545,7 @@ SECTIONS
|
|||
build/src/code/code_0x800AF710.o(.rodata)
|
||||
build/asm/code/code_rodata_z_effect_soft_sprite_old_init.o(.rodata)
|
||||
build/asm/code/code_rodata_flg_set.o(.rodata)
|
||||
. += 0x10;
|
||||
build/asm/code/code_rodata_z_actor.o(.rodata)
|
||||
build/src/code/z_actor_dlftbls.o(.rodata)
|
||||
build/asm/code/code_rodata_z_bgcheck.o(.rodata)
|
||||
|
|
@ -1946,8 +1947,8 @@ SECTIONS
|
|||
{
|
||||
build/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.o(.text)
|
||||
build/asm/overlays/ovl_Arrow_Ice_data.o(.data)
|
||||
build/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.o(.rodata)
|
||||
build/asm/overlays/ovl_Arrow_Ice_rodata.o(.rodata)
|
||||
build/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.o(.rodata)
|
||||
build/asm/overlays/ovl_Arrow_Ice_late_rodata.o(.rodata)
|
||||
ovl_Arrow_Ice_bss_start = .;
|
||||
}
|
||||
|
|
@ -1963,8 +1964,8 @@ SECTIONS
|
|||
{
|
||||
build/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.o(.text)
|
||||
build/asm/overlays/ovl_Arrow_Light_data.o(.data)
|
||||
build/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.o(.rodata)
|
||||
build/asm/overlays/ovl_Arrow_Light_rodata.o(.rodata)
|
||||
build/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.o(.rodata)
|
||||
build/asm/overlays/ovl_Arrow_Light_late_rodata.o(.rodata)
|
||||
ovl_Arrow_Light_bss_start = .;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2116,6 +2116,7 @@
|
|||
0x80110038:("func_80110038",),
|
||||
0x80111CB4:("func_80111CB4",),
|
||||
0x801129E4:("func_801129E4",),
|
||||
0x80112AF4:("func_80112AF4",),
|
||||
0x80112AFC:("func_80112AFC",),
|
||||
0x80112B40:("func_80112B40",),
|
||||
0x80112BE4:("func_80112BE4",),
|
||||
|
|
@ -2171,7 +2172,6 @@
|
|||
0x8011E730:("func_8011E730",),
|
||||
0x8011F0E0:("func_8011F0E0",),
|
||||
0x80120F90:("func_80120F90",),
|
||||
0x80121000:("func_80121000",),
|
||||
0x80121064:("func_80121064",),
|
||||
0x801210E0:("func_801210E0",),
|
||||
0x80121F94:("func_80121F94",),
|
||||
|
|
@ -2892,7 +2892,6 @@
|
|||
0x8015926C:("func_8015926C",),
|
||||
0x80159438:("func_80159438",),
|
||||
0x8015966C:("func_8015966C",),
|
||||
0x8015A144:("func_8015A144",),
|
||||
0x8015B198:("func_8015B198",),
|
||||
0x8015E750:("func_8015E750",),
|
||||
0x8015E7EC:("func_8015E7EC",),
|
||||
|
|
@ -3224,7 +3223,6 @@
|
|||
0x80177060:("func_80177060",),
|
||||
0x80177084:("func_80177084",),
|
||||
0x8017715C:("Sched_ThreadEntry",),
|
||||
0x80177280:("func_80177280",),
|
||||
0x801772A0:("Sched_Start",),
|
||||
0x80177390:("func_80177390",),
|
||||
0x801773A0:("func_801773A0",),
|
||||
|
|
@ -3440,6 +3438,7 @@
|
|||
0x8018450C:("func_8018450C",),
|
||||
0x801845A4:("func_801845A4",),
|
||||
0x801845C8:("func_801845C8",),
|
||||
0x8018462C:("func_8018462C",),
|
||||
0x80184638:("func_80184638",),
|
||||
0x801846AC:("func_801846AC",),
|
||||
0x80184728:("func_80184728",),
|
||||
|
|
@ -3474,6 +3473,12 @@
|
|||
0x80185F64:("func_80185F64",),
|
||||
0x80185F90:("func_80185F90",),
|
||||
0x80186A70:("func_80186A70",),
|
||||
0x80186AB8:("func_80186AB8",),
|
||||
0x80186B28:("func_80186B28",),
|
||||
0x80186B30:("func_80186B30",),
|
||||
0x80186B38:("func_80186B38",),
|
||||
0x80186B68:("func_80186B68",),
|
||||
0x80186B70:("func_80186B70",),
|
||||
0x80186B78:("func_80186B78",),
|
||||
0x80186CAC:("func_80186CAC",),
|
||||
0x80186D60:("func_80186D60",),
|
||||
|
|
@ -3492,18 +3497,43 @@
|
|||
0x80187DE8:("func_80187DE8",),
|
||||
0x80187E58:("func_80187E58",),
|
||||
0x80187F00:("func_80187F00",),
|
||||
0x80187FA8:("func_80187FA8",),
|
||||
0x80187FB0:("func_80187FB0",),
|
||||
0x80187FD0:("func_80187FD0",),
|
||||
0x80187FD8:("func_80187FD8",),
|
||||
0x80187FE0:("func_80187FE0",),
|
||||
0x80187FE8:("func_80187FE8",),
|
||||
0x8018801C:("func_8018801C",),
|
||||
0x80188024:("func_80188024",),
|
||||
0x8018802C:("func_8018802C",),
|
||||
0x80188034:("func_80188034",),
|
||||
0x80188068:("func_80188068",),
|
||||
0x80188070:("func_80188070",),
|
||||
0x80188078:("func_80188078",),
|
||||
0x801880A4:("func_801880A4",),
|
||||
0x801880AC:("func_801880AC",),
|
||||
0x801880B4:("func_801880B4",),
|
||||
0x801880BC:("func_801880BC",),
|
||||
0x801880C4:("func_801880C4",),
|
||||
0x801880E8:("func_801880E8",),
|
||||
0x8018811C:("func_8018811C",),
|
||||
0x80188124:("func_80188124",),
|
||||
0x8018814C:("func_8018814C",),
|
||||
0x80188174:("func_80188174",),
|
||||
0x80188190:("func_80188190",),
|
||||
0x80188198:("func_80188198",),
|
||||
0x801881A0:("func_801881A0",),
|
||||
0x801881A8:("func_801881A8",),
|
||||
0x801881C4:("func_801881C4",),
|
||||
0x801881F8:("func_801881F8",),
|
||||
0x80188224:("func_80188224",),
|
||||
0x8018822C:("func_8018822C",),
|
||||
0x80188234:("func_80188234",),
|
||||
0x8018823C:("func_8018823C",),
|
||||
0x80188244:("func_80188244",),
|
||||
0x8018824C:("func_8018824C",),
|
||||
0x80188254:("func_80188254",),
|
||||
0x8018825C:("func_8018825C",),
|
||||
0x80188264:("func_80188264",),
|
||||
0x80188288:("func_80188288",),
|
||||
0x801882A0:("func_801882A0",),
|
||||
|
|
@ -3517,6 +3547,7 @@
|
|||
0x80188AFC:("func_80188AFC",),
|
||||
0x80188C48:("func_80188C48",),
|
||||
0x80188CB4:("func_80188CB4",),
|
||||
0x80188D20:("func_80188D20",),
|
||||
0x80188D28:("func_80188D28",),
|
||||
0x80188D68:("func_80188D68",),
|
||||
0x80188DDC:("func_80188DDC",),
|
||||
|
|
@ -3532,6 +3563,7 @@
|
|||
0x8018B10C:("func_8018B10C",),
|
||||
0x8018B250:("func_8018B250",),
|
||||
0x8018B318:("func_8018B318",),
|
||||
0x8018B3FC:("func_8018B3FC",),
|
||||
0x8018B474:("func_8018B474",),
|
||||
0x8018B4F8:("func_8018B4F8",),
|
||||
0x8018B520:("func_8018B520",),
|
||||
|
|
@ -3544,6 +3576,7 @@
|
|||
0x8018B740:("func_8018B740",),
|
||||
0x8018B768:("func_8018B768",),
|
||||
0x8018B77C:("func_8018B77C",),
|
||||
0x8018B7AC:("func_8018B7AC",),
|
||||
0x8018B7BC:("func_8018B7BC",),
|
||||
0x8018B8FC:("func_8018B8FC",),
|
||||
0x8018B95C:("func_8018B95C",),
|
||||
|
|
@ -3553,6 +3586,8 @@
|
|||
0x8018BBEC:("func_8018BBEC",),
|
||||
0x8018C380:("func_8018C380",),
|
||||
0x8018C3D8:("func_8018C3D8",),
|
||||
0x8018C4E4:("func_8018C4E4",),
|
||||
0x8018C8B8:("func_8018C8B8",),
|
||||
0x8018C8E8:("func_8018C8E8",),
|
||||
0x8018C93C:("func_8018C93C",),
|
||||
0x8018C994:("func_8018C994",),
|
||||
|
|
@ -3617,15 +3652,18 @@
|
|||
0x80190544:("func_80190544",),
|
||||
0x80190668:("func_80190668",),
|
||||
0x8019067C:("func_8019067C",),
|
||||
0x80190754:("func_80190754",),
|
||||
0x8019075C:("func_8019075C",),
|
||||
0x8019077C:("func_8019077C",),
|
||||
0x80190B08:("func_80190B08",),
|
||||
0x80190B38:("func_80190B38",),
|
||||
0x80190B44:("func_80190B44",),
|
||||
0x80190B50:("func_80190B50",),
|
||||
0x80190BB0:("func_80190BB0",),
|
||||
0x80190F50:("func_80190F50",),
|
||||
0x80190F64:("func_80190F64",),
|
||||
0x80191134:("func_80191134",),
|
||||
0x801911C4:("func_801911C4",),
|
||||
0x801911CC:("func_801911CC",),
|
||||
0x80191240:("func_80191240",),
|
||||
0x801913C8:("func_801913C8",),
|
||||
|
|
@ -3649,6 +3687,9 @@
|
|||
0x801924BC:("func_801924BC",),
|
||||
0x80192514:("func_80192514",),
|
||||
0x80192990:("func_80192990",),
|
||||
0x80192AD0:("func_80192AD0",),
|
||||
0x80192AD8:("func_80192AD8",),
|
||||
0x80192AE0:("func_80192AE0",),
|
||||
0x80192AE8:("func_80192AE8",),
|
||||
0x80192B54:("func_80192B54",),
|
||||
0x80192BAC:("func_80192BAC",),
|
||||
|
|
@ -3669,13 +3710,18 @@
|
|||
0x80193AEC:("func_80193AEC",),
|
||||
0x80193BA0:("func_80193BA0",),
|
||||
0x80193C04:("func_80193C04",),
|
||||
0x80193C24:("func_80193C24",),
|
||||
0x80193C5C:("func_80193C5C",),
|
||||
0x80193CB4:("func_80193CB4",),
|
||||
0x80193D08:("func_80193D08",),
|
||||
0x80193DF0:("func_80193DF0",),
|
||||
0x80193DA4:("func_80193DA4",),
|
||||
0x80193E44:("func_80193E44",),
|
||||
0x80193E6C:("func_80193E6C",),
|
||||
0x80193E9C:("func_80193E9C",),
|
||||
0x80193EA8:("func_80193EA8",),
|
||||
0x80194080:("func_80194080",),
|
||||
0x801942BC:("func_801942BC",),
|
||||
0x80194304:("func_80194304",),
|
||||
0x80194328:("func_80194328",),
|
||||
0x8019435C:("func_8019435C",),
|
||||
|
|
@ -3690,6 +3736,7 @@
|
|||
0x80194710:("func_80194710",),
|
||||
0x80194750:("func_80194750",),
|
||||
0x80194790:("func_80194790",),
|
||||
0x80194804:("func_80194804",),
|
||||
0x80194840:("func_80194840",),
|
||||
0x801948B0:("func_801948B0",),
|
||||
0x80194930:("func_80194930",),
|
||||
|
|
@ -3790,6 +3837,7 @@
|
|||
0x8019B6B4:("func_8019B6B4",),
|
||||
0x8019BC44:("func_8019BC44",),
|
||||
0x8019BE98:("func_8019BE98",),
|
||||
0x8019C1C0:("func_8019C1C0",),
|
||||
0x8019C1D0:("func_8019C1D0",),
|
||||
0x8019C268:("func_8019C268",),
|
||||
0x8019C2E4:("func_8019C2E4",),
|
||||
|
|
@ -3816,7 +3864,12 @@
|
|||
0x8019D8E4:("func_8019D8E4",),
|
||||
0x8019DF28:("func_8019DF28",),
|
||||
0x8019DF64:("func_8019DF64",),
|
||||
0x8019DFF8:("func_8019DFF8",),
|
||||
0x8019E000:("func_8019E000",),
|
||||
0x8019E00C:("func_8019E00C",),
|
||||
0x8019E014:("func_8019E014",),
|
||||
0x8019E0FC:("func_8019E0FC",),
|
||||
0x8019E104:("func_8019E104",),
|
||||
0x8019E110:("func_8019E110",),
|
||||
0x8019E14C:("func_8019E14C",),
|
||||
0x8019E324:("func_8019E324",),
|
||||
|
|
@ -3867,13 +3920,17 @@
|
|||
0x801A0238:("func_801A0238",),
|
||||
0x801A026C:("func_801A026C",),
|
||||
0x801A0318:("func_801A0318",),
|
||||
0x801A0450:("func_801A0450",),
|
||||
0x801A046C:("func_801A046C",),
|
||||
0x801A0554:("func_801A0554",),
|
||||
0x801A05E4:("func_801A05E4",),
|
||||
0x801A05F0:("func_801A05F0",),
|
||||
0x801A0654:("func_801A0654",),
|
||||
0x801A0810:("func_801A0810",),
|
||||
0x801A0868:("func_801A0868",),
|
||||
0x801A09D4:("func_801A09D4",),
|
||||
0x801A0C70:("func_801A0C70",),
|
||||
0x801A0C90:("func_801A0C90",),
|
||||
0x801A0CB0:("func_801A0CB0",),
|
||||
0x801A0E44:("func_801A0E44",),
|
||||
0x801A1290:("func_801A1290",),
|
||||
|
|
@ -3891,6 +3948,8 @@
|
|||
0x801A1F88:("func_801A1F88",),
|
||||
0x801A1FB4:("func_801A1FB4",),
|
||||
0x801A2090:("func_801A2090",),
|
||||
0x801A21FC:("func_801A21FC",),
|
||||
0x801A2460:("func_801A2460",),
|
||||
0x801A246C:("func_801A246C",),
|
||||
0x801A2544:("func_801A2544",),
|
||||
0x801A257C:("func_801A257C",),
|
||||
|
|
@ -3909,6 +3968,7 @@
|
|||
0x801A2E54:("func_801A2E54",),
|
||||
0x801A2ED8:("func_801A2ED8",),
|
||||
0x801A2F88:("func_801A2F88",),
|
||||
0x801A2FC4:("func_801A2FC4",),
|
||||
0x801A3000:("func_801A3000",),
|
||||
0x801A3038:("func_801A3038",),
|
||||
0x801A3098:("func_801A3098",),
|
||||
|
|
@ -3917,6 +3977,7 @@
|
|||
0x801A3238:("func_801A3238",),
|
||||
0x801A32CC:("func_801A32CC",),
|
||||
0x801A3590:("func_801A3590",),
|
||||
0x801A36F0:("func_801A36F0",),
|
||||
0x801A3950:("func_801A3950",),
|
||||
0x801A39F8:("func_801A39F8",),
|
||||
0x801A3A7C:("func_801A3A7C",),
|
||||
|
|
@ -3926,6 +3987,7 @@
|
|||
0x801A3B90:("func_801A3B90",),
|
||||
0x801A3CD8:("func_801A3CD8",),
|
||||
0x801A3CF4:("func_801A3CF4",),
|
||||
0x801A3D54:("func_801A3D54",),
|
||||
0x801A3D98:("func_801A3D98",),
|
||||
0x801A3E38:("func_801A3E38",),
|
||||
0x801A3EC0:("func_801A3EC0",),
|
||||
|
|
@ -3964,11 +4026,14 @@
|
|||
0x801A4EB8:("func_801A4EB8",),
|
||||
0x801A4FD8:("func_801A4FD8",),
|
||||
0x801A5080:("func_801A5080",),
|
||||
0x801A50C0:("func_801A50C0",),
|
||||
0x801A5100:("func_801A5100",),
|
||||
0x801A510C:("func_801A510C",),
|
||||
0x801A5118:("func_801A5118",),
|
||||
0x801A51F0:("func_801A51F0",),
|
||||
0x801A5228:("func_801A5228",),
|
||||
0x801A5390:("func_801A5390",),
|
||||
0x801A53DC:("func_801A53DC",),
|
||||
0x801A53E8:("func_801A53E8",),
|
||||
0x801A541C:("func_801A541C",),
|
||||
0x801A5488:("func_801A5488",),
|
||||
|
|
@ -4007,9 +4072,10 @@
|
|||
0x801A89D0:("func_801A89D0",),
|
||||
0x801A8A50:("func_801A8A50",),
|
||||
0x801A8ABC:("func_801A8ABC",),
|
||||
0x801A8B14:("func_801A8B14",),
|
||||
0x801A8B2C:("func_801A8B2C",),
|
||||
0x801A8BD0:("func_801A8BD0",),
|
||||
0x801A8D5C:("func_801A8D5C",),
|
||||
0x801A8E90:("func_801A8E90",),
|
||||
0x801A9768:("func_801A9768",),
|
||||
0x801A982C:("func_801A982C",),
|
||||
0x801A99B8:("func_801A99B8",),
|
||||
|
|
@ -4642,7 +4708,6 @@
|
|||
0x8084CCEC:("func_8084CCEC",),
|
||||
0x8084CE84:("func_8084CE84",),
|
||||
0x8084D18C:("func_8084D18C",),
|
||||
0x8084D2FC:("func_8084D2FC",),
|
||||
0x8084D4EC:("func_8084D4EC",),
|
||||
0x8084D770:("func_8084D770",),
|
||||
0x8084D820:("func_8084D820",),
|
||||
|
|
@ -4834,7 +4899,6 @@
|
|||
0x8085B820:("func_8085B820",),
|
||||
0x8085B854:("func_8085B854",),
|
||||
0x8085B930:("func_8085B930",),
|
||||
0x8085DA08:("D_8085DA08",),
|
||||
0x80862B70:("func_80862B70",),
|
||||
0x80862CBC:("func_80862CBC",),
|
||||
0x80862EDC:("func_80862EDC",),
|
||||
|
|
|
|||
11906
tables/variables.txt
11906
tables/variables.txt
File diff suppressed because it is too large
Load Diff
107
tools/disasm.py
107
tools/disasm.py
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
import argparse, os, struct, ast, bisect
|
||||
import argparse, os, struct, ast, bisect, math
|
||||
|
||||
SPLIT_FILES = True # TODO this should be a flag somewhere
|
||||
|
||||
|
|
@ -159,6 +159,63 @@ def write_header(file, is_data):
|
|||
else:
|
||||
file.write(".section .data\n\n")
|
||||
|
||||
file.write(".balign 16\n\n")
|
||||
|
||||
def format_string(data_bytes, output_ends = True, force_ascii = False):
|
||||
"""
|
||||
Swiss Cheese
|
||||
"""
|
||||
hex_digits = "0123456789abcdefABCDEF"
|
||||
result = ""
|
||||
directive = "ascii" if force_ascii else "asciz"
|
||||
|
||||
if 0x8C in data_bytes or 0x8D in data_bytes or 0x1B in data_bytes:
|
||||
char = ""
|
||||
index = None
|
||||
if 0x8C in data_bytes:
|
||||
char = "\\x8C"
|
||||
index = data_bytes.index(0x8C)
|
||||
elif 0x8D in data_bytes:
|
||||
char = "\\x8D"
|
||||
index = data_bytes.index(0x8D)
|
||||
elif 0x1B in data_bytes:
|
||||
char = "\\x1B"
|
||||
index = data_bytes.index(0x1B)
|
||||
else:
|
||||
assert False , "???"
|
||||
part1 = format_string(data_bytes[0:index], output_ends=False)
|
||||
part2 = format_string(data_bytes[index+1:], output_ends=False)
|
||||
if part2 != "":
|
||||
result = part1 + ("\"\n .ascii \"" if part2[0] in hex_digits and part1 != "" else "") + \
|
||||
char + ("\"\n .asciz \"" if part2[0] in hex_digits else "") + part2
|
||||
if output_ends and part2[0] in hex_digits and part1 == "":
|
||||
directive = "ascii"
|
||||
else:
|
||||
result = part1 + ("\"\n .ascii \"" if part2[0] in hex_digits and part1 != "" else "") + char + "\"\n"
|
||||
else:
|
||||
result = data_bytes.decode("EUC-JP").replace("\n", "\\n").replace("\r", "\\r").replace("\t", "\\t").replace("\0", "")
|
||||
|
||||
return (("." + directive + " \"") if output_ends else "") + result + ("\"" if output_ends else "")
|
||||
|
||||
def format_float(f):
|
||||
"""
|
||||
naive approach to reduce float decimals, also for doubles
|
||||
"""
|
||||
if math.isnan(f) or (type(f) == float and f == 4294967296.0):
|
||||
return str(f)
|
||||
struct_fmt = ">f" if type(f) == float else ">d"
|
||||
|
||||
float_str = str(f)
|
||||
precision = len(float_str.split(".")[1].strip())
|
||||
word = struct.pack(struct_fmt, f)
|
||||
while precision != 0:
|
||||
new_f = round(f,precision-1)
|
||||
precision -= 1
|
||||
if struct.pack(struct_fmt, new_f) != word:
|
||||
return f
|
||||
else:
|
||||
f = new_f
|
||||
return f
|
||||
|
||||
# TODO add code_regions?
|
||||
class Disassembler:
|
||||
|
|
@ -444,16 +501,50 @@ class Disassembler:
|
|||
with open(filename, 'w') as f:
|
||||
write_header(f, self.is_in_data_or_undef(file.vaddr))
|
||||
|
||||
# strings can span many words and more often than not do
|
||||
# but are luckily always 4-byte aligned
|
||||
string_start = -1
|
||||
string_data = bytearray()
|
||||
force_ascii_str = False # hack for non-null-terminated strings in .data
|
||||
|
||||
# whether to output floats
|
||||
is_floats = False
|
||||
|
||||
for i in range(0, file.size // 4):
|
||||
inst = file.get_inst(i)
|
||||
addr = file.vaddr + i*4
|
||||
inst = file.get_inst(i)
|
||||
|
||||
if addr in self.objects and SPLIT_FILES:
|
||||
# if currently accumulating a string, write it out as-is since there's no way it's extending over a file boundary
|
||||
if string_start != -1:
|
||||
f.write("glabel %s\n" % self.make_load(string_start))
|
||||
f.write("/* %06d 0x%08X */ %s\n .balign 4\n" % ((string_start - file.vaddr)//4, string_start, format_string(string_data, force_ascii=force_ascii_str)))
|
||||
string_data = bytearray()
|
||||
# reset string writing
|
||||
string_start = -1
|
||||
f.close()
|
||||
filename = self.build_disassembled_path(path, addr, file)
|
||||
f = open(filename, 'w')
|
||||
write_header(f, self.is_in_data_or_undef(addr))
|
||||
|
||||
var = known_vars.get(addr, None)
|
||||
if var is not None:
|
||||
is_floats = var[1] == "f32"
|
||||
# is_doubles = var[1] == "f64"
|
||||
# end of the string, write it out
|
||||
if string_start != -1:
|
||||
f.write("glabel %s\n" % self.make_load(string_start))
|
||||
f.write("/* %06d 0x%08X */ %s\n .balign 4\n" % ((string_start - file.vaddr)//4, string_start, format_string(string_data, force_ascii=force_ascii_str)))
|
||||
string_data = bytearray()
|
||||
# string check
|
||||
string_start = addr if (var[1] == "char" and var[2].startswith("[") and var[2].endswith("]")) else -1
|
||||
force_ascii_str = addr in [0x801D0708] # non-null-terminated strings in .data
|
||||
|
||||
# accumulate string data
|
||||
if string_start != -1:
|
||||
string_data.extend(file.data[i*4:(i+1)*4])
|
||||
continue
|
||||
|
||||
if addr in self.labels and addr not in self.switch_cases:
|
||||
f.write(".L%08X:\n" % addr)
|
||||
if addr in self.switch_cases:
|
||||
|
|
@ -505,9 +596,19 @@ class Disassembler:
|
|||
data_stream <<= 16
|
||||
print_head += 2
|
||||
else:
|
||||
f.write("/* %06d 0x%08X */ .word\t0x%08X\n" % (i, addr, data_stream & 0xFFFFFFFF))
|
||||
if is_floats:
|
||||
flt = struct.unpack(">f", struct.pack(">I", data_stream & 0xFFFFFFFF))[0]
|
||||
f.write("/* %06d 0x%08X */ .float\t%s\n" % (i, addr, format_float(flt)))
|
||||
else:
|
||||
f.write("/* %06d 0x%08X */ .word\t0x%08X\n" % (i, addr, data_stream & 0xFFFFFFFF))
|
||||
data_stream <<= 32
|
||||
print_head += 4
|
||||
# catch strings at the end of a section
|
||||
if string_start != -1:
|
||||
f.write("glabel %s\n" % self.make_load(string_start))
|
||||
f.write("/* %06d 0x%08X */ %s\n .balign 4\n" % ((string_start - file.vaddr)//4, string_start, format_string(string_data, force_ascii=force_ascii_str)))
|
||||
string_data = bytearray()
|
||||
string_start = -1
|
||||
|
||||
def determine_load_ref_impl(self, file, inst_i, start_i, depth, from_branch=False, visited=set()):
|
||||
candidates = []
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ def split_asm_and_rodata():
|
|||
if line.startswith('glabel') and not line.startswith('glabel L80'):
|
||||
current_rodata = line.split()[1]
|
||||
assert(current_rodata != '')
|
||||
if '.byte' in line or '.short' in line or '.word' in line:
|
||||
if any([directive in line for directive in ['.byte', '.half', '.short', '.word', '.ascii', '.asciz', '.float', '.double']]):
|
||||
rodata_entries.append([current_rodata, line, False])
|
||||
f.close()
|
||||
|
||||
|
||||
with open(args.input, 'r') as f:
|
||||
current_file = None
|
||||
relevant_rodata = []
|
||||
|
|
@ -91,7 +91,7 @@ def split_asm_and_rodata():
|
|||
writing = True
|
||||
file_names.append(file_name)
|
||||
|
||||
if '.byte' in line or '.short' in line or '.word' in line:
|
||||
if any([directive in line for directive in ['.byte', '.half', '.short', '.word', '.ascii', '.asciz', '.float', '.double']]):
|
||||
writing = False
|
||||
|
||||
for entries in rodata_entries:
|
||||
|
|
@ -174,7 +174,7 @@ if __name__ == '__main__':
|
|||
|
||||
file_names = []
|
||||
|
||||
if "ovl_" in str(args.input) and not any(ovlFile in str(args.input) for ovlFile in ["ovl_Arrow_Ice", "ovl_Arrow_Light", "ovl_Bg_Dkjail_Ivy", "ovl_Bg_Ikana_Mirror", "ovl_Boss_02", "ovl_Boss_07", "ovl_Boss_Hakugin", "ovl_Elf_Msg", "ovl_Elf_Msg2", "ovl_Elf_Msg3", "ovl_Elf_Msg4", "ovl_Elf_Msg5", "ovl_En_Az", "ovl_En_Bigokuta", "ovl_En_Bigpamet", "ovl_En_Bigpo", "ovl_En_Bigslime", "ovl_En_Box", "ovl_En_Butte", "ovl_En_Col_Man", "ovl_En_Crow", "ovl_En_Death", "ovl_En_Elf", "ovl_En_Elforg", "ovl_En_Encount3", "ovl_En_Encount4", "ovl_En_Fish", "ovl_En_Fish2", "ovl_En_Fsn", "ovl_En_Honotrap", "ovl_En_Horse", "ovl_En_Horse_Game", "ovl_En_Invadepoh", "ovl_En_Ishi", "ovl_En_Kame", "ovl_En_Kanban", "ovl_En_Kusa2", "ovl_En_M_Thunder", "ovl_En_Maruta", "ovl_En_Mushi2", "ovl_En_Okuta", "ovl_En_Ossan", "ovl_En_Pametfrog", "ovl_En_Peehat", "ovl_En_Rg", "ovl_En_Ruppecrow", "ovl_En_Slime", "ovl_En_Sob1", "ovl_En_Syateki_Man", "ovl_En_Test7", "ovl_En_Trt", "ovl_En_Wiz_Fire", "ovl_Mir_Ray", "ovl_Obj_Bombiwa", "ovl_Obj_Driftice", "ovl_Obj_Hariko", "ovl_Obj_Iceblock", "ovl_Obj_Mure", "ovl_Obj_Snowball2", "ovl_Obj_Toudai", "ovl_select"]):
|
||||
if "ovl_" in str(args.input) and not any(ovlFile in str(args.input) for ovlFile in ["ovl_Bg_Dkjail_Ivy", "ovl_Bg_Ikana_Mirror", "ovl_Boss_02", "ovl_Boss_07", "ovl_Boss_Hakugin", "ovl_Elf_Msg", "ovl_Elf_Msg2", "ovl_Elf_Msg3", "ovl_Elf_Msg4", "ovl_Elf_Msg5", "ovl_En_Az", "ovl_En_Bigokuta", "ovl_En_Bigpamet", "ovl_En_Bigpo", "ovl_En_Bigslime", "ovl_En_Box", "ovl_En_Butte", "ovl_En_Col_Man", "ovl_En_Crow", "ovl_En_Death", "ovl_En_Elf", "ovl_En_Elforg", "ovl_En_Encount3", "ovl_En_Encount4", "ovl_En_Fish", "ovl_En_Fish2", "ovl_En_Fsn", "ovl_En_Honotrap", "ovl_En_Horse", "ovl_En_Horse_Game", "ovl_En_Invadepoh", "ovl_En_Ishi", "ovl_En_Kame", "ovl_En_Kanban", "ovl_En_Kusa2", "ovl_En_M_Thunder", "ovl_En_Maruta", "ovl_En_Mushi2", "ovl_En_Okuta", "ovl_En_Ossan", "ovl_En_Pametfrog", "ovl_En_Peehat", "ovl_En_Rg", "ovl_En_Ruppecrow", "ovl_En_Slime", "ovl_En_Sob1", "ovl_En_Syateki_Man", "ovl_En_Test7", "ovl_En_Trt", "ovl_En_Wiz_Fire", "ovl_Mir_Ray", "ovl_Obj_Bombiwa", "ovl_Obj_Driftice", "ovl_Obj_Hariko", "ovl_Obj_Iceblock", "ovl_Obj_Mure", "ovl_Obj_Snowball2", "ovl_Obj_Toudai", "ovl_select"]):
|
||||
split_asm_and_rodata()
|
||||
exit(0)
|
||||
|
||||
|
|
|
|||
12
undef.txt
12
undef.txt
|
|
@ -172,6 +172,7 @@ D_801EDE30 = code_bss_start + 0x00009E90;
|
|||
D_801EDE40 = code_bss_start + 0x00009EA0;
|
||||
D_801EDE78 = code_bss_start + 0x00009ED8;
|
||||
D_801EDEB0 = code_bss_start + 0x00009F10;
|
||||
D_801EDEBC = code_bss_start + 0x00009F1C;
|
||||
D_801EDEC8 = code_bss_start + 0x00009F28;
|
||||
D_801EDF00 = code_bss_start + 0x00009F60;
|
||||
D_801EDF38 = code_bss_start + 0x00009F98;
|
||||
|
|
@ -179,19 +180,30 @@ D_801EDF48 = code_bss_start + 0x00009FA8;
|
|||
D_801EDF58 = code_bss_start + 0x00009FB8;
|
||||
D_801EDF90 = code_bss_start + 0x00009FF0;
|
||||
D_801EDFC8 = code_bss_start + 0x0000A028;
|
||||
D_801EDFD4 = code_bss_start + 0x0000A034;
|
||||
D_801EDFE0 = code_bss_start + 0x0000A040;
|
||||
D_801EDFF0 = code_bss_start + 0x0000A050;
|
||||
D_801EE000 = code_bss_start + 0x0000A060;
|
||||
D_801EE038 = code_bss_start + 0x0000A098;
|
||||
D_801EE070 = code_bss_start + 0x0000A0D0;
|
||||
D_801EE0A4 = code_bss_start + 0x0000A104;
|
||||
D_801EE0D8 = code_bss_start + 0x0000A138;
|
||||
D_801EE0E8 = code_bss_start + 0x0000A148;
|
||||
D_801EE11C = code_bss_start + 0x0000A17C;
|
||||
D_801EE150 = code_bss_start + 0x0000A1B0;
|
||||
D_801EE188 = code_bss_start + 0x0000A1E8;
|
||||
D_801EE1C0 = code_bss_start + 0x0000A220;
|
||||
D_801EE1C4 = code_bss_start + 0x0000A224;
|
||||
D_801EE1C8 = code_bss_start + 0x0000A228;
|
||||
D_801EE1D0 = code_bss_start + 0x0000A230;
|
||||
D_801EE1D4 = code_bss_start + 0x0000A234;
|
||||
D_801EE1D8 = code_bss_start + 0x0000A238;
|
||||
D_801EE1E0 = code_bss_start + 0x0000A240;
|
||||
D_801EE1E4 = code_bss_start + 0x0000A244;
|
||||
D_801EE1E8 = code_bss_start + 0x0000A248;
|
||||
D_801EE1F0 = code_bss_start + 0x0000A250;
|
||||
D_801EE1F4 = code_bss_start + 0x0000A254;
|
||||
D_801EE1F8 = code_bss_start + 0x0000A258;
|
||||
D_801EE200 = code_bss_start + 0x0000A260;
|
||||
D_801EE6C8 = code_bss_start + 0x0000A728;
|
||||
D_801EE700 = code_bss_start + 0x0000A760;
|
||||
|
|
|
|||
Loading…
Reference in New Issue