decomp-toolkit icon indicating copy to clipboard operation
decomp-toolkit copied to clipboard

[DWARF] Use MIPS register names for DWARF dumped from MIPS binaries

Open 1superchip opened this issue 10 months ago • 0 comments

DTK was designed around PPC but it also supports LE DWARF info which allows it to be used for PS2 binaries that contain DWARF v1. When dumping DWARF info from MIPS binaries, the register names used are PPC names. Using the MIPS names for registers would help when decompiling rather than seeing the PPC names.

Related source: https://github.com/encounter/decomp-toolkit/blob/7e15810af14c65c30201313607c9093721a8cdf3/src/util/dwarf.rs#L1813

MIPS register names: https://en.wikibooks.org/wiki/MIPS_Assembly/Register_File

In the following code, r29 is actually sp for MIPS.

/*
    Compile unit: C:\work\sf33rd\AcrSDK\ps2\flps2vram.c
    Producer: MW MIPS C Compiler
    Language: C
    Code range: 0x003FC830 -> 0x003FC968
*/
// Range: 0x3FC830 -> 0x3FC968
static void PageConv4to32(unsigned char * p_input /* r29+0xB0 */, unsigned char * p_output /* r29+0xC0 */, signed int p_page_w /* r29+0xD0 */) {
    // Blocks
    /* anonymous block */ {
        // Range: 0x3FC830 -> 0x3FC968
        signed int i; // r17
        signed int j; // r16
        signed int nb; // r18
        signed int * tbl; // r19
        unsigned char * pi; // r29+0xAC
        unsigned char * po; // r30
        signed int n_width; // r23
        signed int n_height; // r22
        signed int i_size; // r21
        signed int o_size; // r20
    }
}

1superchip avatar Feb 03 '25 22:02 1superchip