Dolphin, the GameCube and Wii emulator - Forums
Decompilation, automate preliminary work? - Printable Version

+- Dolphin, the GameCube and Wii emulator - Forums (https://forums.dolphin-emu.org)
+-- Forum: Game Modifications (https://forums.dolphin-emu.org/Forum-game-modifications)
+--- Forum: Cheats, Hacks, & Game Patches (https://forums.dolphin-emu.org/Forum-cheats-hacks-game-patches)
+--- Thread: Decompilation, automate preliminary work? (/Thread-decompilation-automate-preliminary-work)



Decompilation, automate preliminary work? - Yoshimaster96 - 12-28-2016

I know that it'll take a long time, and that it can't be done completely automatically, however...

I'd like to at the VERY LEAST have a tool that'll split it into functions and convert assembly instructions into small statements that can later be optimized by the user.

For example (code from http://www.csd.uwo.ca/~mburrel/stuff/ppc-asm.html):

ASSEMBLY:

bar:
mflr r0 // set up the stack frame
stw r0, 8(r1)
stwu r1, -16(r1)
addi r3, r3, 3 // add 3 to the argument and return it
addi r1, r1, 16 // destroy the stack frame
lwz r0, 8(r1)
mtlr r0
blr // return

.globl _main
_main:
mflr r0 // set up the stack frame
stw r0, 8(r1)
stwu r1, -16(r1)
lis r3, hi16(847318093) // load big number into r3
ori r3, r3, lo16(847318092)
bl bar // call stuff
addi r1, r1, 16 // destroy the stack frame
lwz r0, 8(r1)
mtlr r0
blr // return


C CODE:

#include <stdint.h>
uint32_t regs[32];

uint32_t bar(uint32_t a)
{
//ctors automatically removed
regs[3] = a+3; //addi r3,r3,3
return regs[3]; //modification to r3 detected
//dtors automatically removed
}

main()
{
//ctors automatically removed
regs[3] = (847318093)&0xFFFF0000; //lis r3, hi16(847318093)
regs[3] |= (847318093)>>16; //ori r3, r3, lo16(847318093)
bar(regs[3]); //bl bar
//dtors automatically removed
}

As you can see, I don't have high expectations, but ideally functions should be detected and separated, stack construction and destruction in functions omitted, and everything else has a 1 to 1 correspondence from assembly opcode to C statement. Is there such a tool? Or would I have to make it myself?


RE: Decompilation, automate preliminary work? - DrHouse64 - 01-03-2017

That's interesting, the only thing I can find about this are softs like boomerang, IDA or PPC2C.