-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decompiler doesn't work for me #278
Comments
Usage instructions are somewhat hidden in the README, but they are there:
Which is to say, m2c isn't able to disassemble MIPS on its own, you need to do that yourself first. This may involve applying some heuristics to detect and give names to symbols, e.g. you may want to say |
I have this code disassembled with MIPS bytecode disassembler which looks like this:
Is it suitable for m2c? |
Roughly. It chokes on mtc0 and mfc0 because they're supposed to take two arguments, but other than that:
Warning: missing "jr $ra" in last block (.initial).
void foo(void) {
M2C_ERROR(/* mtc0 $0, $18 */);
M2C_ERROR(/* mtc0 $0, $19 */);
M2C_ERROR(/* mtc0 $0, $13 */);
M2C_ERROR(/* mtc0 $2, $12 */);
M2C_ERROR(/* mtc0 $2, $16 */);
(? (*)())0x80004214();
M2C_ERROR(/* mtc0 $2, $12 */);
} We don't support mtc0/mfc0 because there's no compilers that generate them and so it hasn't been prioritized, so the output is pretty much garbage, but it does work. I would recommend spimdisasm for the disassembler, it would give you nicer asm (e.g. nops instead of sll $0, $0, 0, and register names). |
I will try spimdisasm. What is proper command options for m2c in my case? |
|
I installed spimdisasm, can't figure out the correct command format, it have a vaste amount of various options, readme isn't too helpful. |
Yeah, it's a bit complex... normally in the N64 matching decomp world it's used in combination with splat (which is somewhat complex to setup too); I don't know if matching decomp is what you're interested in though. You can join the decomp.me discord if you're interested in getting in touch with people who know this tooling better. Ghidra is also pretty decent, especially if you don't care about matching decomp or you're targeting code compiled by a more modern compiler. |
well, fist I'd want try a spimdisasm + m2c, to see what they can do. I just a little confused about the |
From the readme |
yes, I used this command, where I got confused is just how to specify input file and output file positional arguments. |
|
Up to you, either should work. I doubt you have 300 MB of code though, most of that is probably data. The file you posted has a lot of invalid instructions, which is probably why it's failed to disassemble. But again this isn't really the right forum for that. |
Invalid instructions when disassembling with spimdisasm? |
Yes, the .s file clearly says so if you open it and look at what it contains |
So, I used a recommended utility (spimdisasm) to disassemble file, but it didn't work because it can't handle all types of files and formats and has limited capabilities. |
I don't think that's the right takeaway, I think it's more likely a usage error in trying to disassemble something as code that isn't actually code. |
so tried again with new disassembled file, output still have some invalid instructions, but its not possible to avoid them. m2c decompiler still fails. Is it able to process only the simple kind of files, like games, nintendo, etc? |
No, both spimdisasm and m2c are general-purpose tools. m2c erroring here is expected, since you're not giving it any asm instructions to process. It definitely looks like you're using spimdisasm wrong; you both somehow ending up with symbol names from the n64 stdlib and not disassembling anything. Again, I can't help you with that, please ask someone who knows that tool. |
that's strange. I used command |
I tried your m2c decompiler. I've installed dependencies and tried to run against the raw MIPS machine code (image.out)
The decompiler does not works for me. Possibly, I specified incomplete or incorrect options, though.
The image.out is results of extraction of raw MIPS code using Broadcom ProgramStore tool. Compiler C++
ProgramStore -x -f file.bin -o image.out
The code is loaded at RAM address 0x80004000
Can you advise?
image.out.zip
The text was updated successfully, but these errors were encountered: