Compile + Decompile ASM with DevKitPPC (Linux)
Compile + Decompile ASM with DevkitPPC (Linux)

NOTE: This guide is for Linux users only.

NOTE: This is NOT meant to replace any compiler+decompiler regarding ASM codes (such as WiiRDGUI, PyiiASMH), it's just for general PowerPC ASM compiling+decompiling.

NOTE: Specific Gekko Broadway Language instructions for Quantization and Dequantization, and the dcbz_l instruction are not supported.

Have Devkit installed and working (For Debian, I have an Installation Guide -

This guide will teach you how to compile ASM instructions (in a text file) to a final output in your terminal screen. This guide assumes your ASM txt file is 'example.txt' in the your home user account directory. 

This guide will also teach you how to decompile ASM instructions of a binary file and display the source on your terminal screen.

TO COMPILE ASSEMBLY (into binary file)

1. Navigate to DevkitPPC binutils

Open a terminal to where you installed your Devkit (for me, I installed mines to /opt)

cd /opt/devkitpro/devkitPPC/bin

2. Compile the ASM instructions to object code

sudo ./powerpc-eabi-as -mregnames -m750cl /home/yourusername/example.txt -o /home/yourusername/objectcode.o

3. Build the binary file from the object code

sudo ./powerpc-eabi-objcopy -O "binary" /home/yourusername/objectcode.o /home/yourusername/asm.bin

4. Print the compiled Hex byte code

cd /home/yousername
xxd -p -c 4 -u asm.bin

The compiled instructions (one word per line) are shown. If desired, you can instead open up the asm.bin file in a Hex Editor to view the compiled instructions.

TO DECOMPILE ASSEMBLY (from binary file)

1. Navigate to binutils

cd /opt/devkitpro/devkitPPC/bin

2. Disassemble the binary file, display results on terminal screen

sudo ./powerpc-eabi-objdump -b binary -m powerpc:750 -M 750cl -D -EB /home/yourusername/asm.bin

The source will be displayed on the screen. Please note branch instructions will NOT have normal hex-offset values. The values in the branch instructions are for the addresses within the binary file itself. (Example: b 0x14 = branch to address 0x00000014 of the binary file)

Final NOTES: Please note that older versions of devkit's binutils and possible future versions may not work with this guide.

Versions of executables used in this guide:
GNU Binutils Version 2.30

Forum Jump:

Users browsing this thread: 1 Guest(s)