dis_single_func.py is a wrapper script around ndsdisasm to disassemble NDS Functions, with XMap support.
Install WSL1
using the same instructions for the Platinum repo.
Run the following command to install libcapstone:
sudo apt install libcapstone-dev
Clone ndsdisasm with the following command. ndsdisasm
in the command will be the name of the destination folder:
git clone https://github.com/luckytyphlosion/gbadisasm --single-branch --branch dism_modules ndsdisasm
Change directory to ndsdisasm
:
cd ndsdisasm
Run make
to build ndsdisasm
:
make
Have a Platinum v1.0 US ROM and a Platinum v1.0 XMap in the same directory as dis_single_func.py
.
To see the compiled assembly for a function:
python3 dis_single_func.py -xrs -f <function_name> -b <ROM name, defaults to pokeplatinum_us.nds> \
-y <XMap filename, defaults to ../master_cpuj00/bin/ARM9-TS/Rom/main.nef.xMAP>
Alternatively, rename the values assigned to BASEROM_FILE_DEFAULT
and XMAP_FILE_DEFAULT
in the python script.
(-b
and -y
will be omitted from further samples)
If there are multiple functions with the same name (this happens because of static functions):
python3 dis_single_func.py -xrs -f <function_name> -w <which function, 0-indexed>
To disassemble ARM:
python3 dis_single_func.py -xrsa -f <function_name>
To disassemble from an address (takes precedence over function name lookup). This is necessary for C++ symbols with weird names:
python3 dis_single_func.py -xrs [-f <function_name> -i <address> \
[-v <overlay ID, excluding this disassembles the static block>]
To open the disassembled file in Notepad++ 64-bit ("Program Files") after the file is created:
python3 dis_single_func.py -xnrs -f <function_name>
Options -f, -b, -y, -w, -i, and -v are the same.
Have the Platinum repo named as master_cpuj00 aside the ndsdisasm repo, i.e.:
ndsdisasm/
master_cpuj00/
Do not specify -b
or -y
(note: you will need to modify BASEROM_FILE_DEFAULT
and XMAP_FILE_DEFAULT
back to their original values).
To see the compiled assembly (mainrom) compared with the actual assembly for a function:
python3 dis_single_func.py -x -f <function_name>
Options -f, -b, -y, -w, -i, and -v are the same.
To see the compiled assembly (mainrom) compared with the actual assembly for a function:
python3 dis_single_func.py -x -f <function_name> -b <baserom name> \
-m <mainrom (compiled ROM) name> -y <XMap filename>
Alternatively, rename the values assigned to BASEROM_FILE_DEFAULT
, MAINROM_FILE_DEFAULT
, and XMAP_FILE_DEFAULT
in the python script.
- Support having a "baserom" XMap so that the generated baserom assembly can take advantage of forward references (references to symbols after the function, can only be enabled if there are no shifts as otherwise the symbol addresses won't match up)
- Have source inlining (for baserom) by disassembling the object file and then matching it up with the assembly (
./sdk/cw/arm_tools/command_line_tools/mwldarm.exe -dis <path to object file> > <output filename>
)