GCC: Difference between revisions

From Decompedia
Jump to navigation Jump to search
No edit summary
Line 11: Line 11:
==== PSX ====
==== PSX ====


* 2.6.0
* [[PSY-Q]] toolchain
* 2.7.2


=== Tips and Tricks for Decompiling ===
=== Decompilation patterns ===
Todo add https://github.com/pmret/papermario/wiki/GCC-2.8.1-Tips-and-Tricks
Todo add https://github.com/pmret/papermario/wiki/GCC-2.8.1-Tips-and-Tricks


Todo add https://hackmd.io/eYQR3yfhQymeTGsVM-SpEg
Todo add https://hackmd.io/eYQR3yfhQymeTGsVM-SpEg
==== Conditional range ====
Used when comparing a variable to a specific range of integers.
if (((u32)(var_a0 - 0xE)) < 9)
This can be translated into
if (var_a0 >= 0xE && var_a0 < 9 + 0xE)
And can be simplified as
if (var_a0 > 13 && var_a0 < 23)
The way it works is that if var_a0 is less than 14, when 14 is subtracted and then converted to unsigned then it will be greater than 9, effectively being equivalent to the conditional range prior to optimization.

Revision as of 14:10, 26 March 2023

GCC is one of the most widely used compilers, and that holds true for game development. A large proportion of N64 games were compiled with GCC. However, there are many different versions of GCC. Due to its open source nature, some development houses made custom modifications to official releases, such as KMC GCC. The community has had to reverse-engineer these differences for some games in order to reproduce a compiler that can be used for matching decomp.

Below are the known GCC versions and some examples of games / projects that used them. (todo: add links and pages for these compilers and projects)

N64

PSX

Decompilation patterns

Todo add https://github.com/pmret/papermario/wiki/GCC-2.8.1-Tips-and-Tricks

Todo add https://hackmd.io/eYQR3yfhQymeTGsVM-SpEg


Conditional range

Used when comparing a variable to a specific range of integers.

if (((u32)(var_a0 - 0xE)) < 9) 

This can be translated into

if (var_a0 >= 0xE && var_a0 < 9 + 0xE) 

And can be simplified as

if (var_a0 > 13 && var_a0 < 23) 

The way it works is that if var_a0 is less than 14, when 14 is subtracted and then converted to unsigned then it will be greater than 9, effectively being equivalent to the conditional range prior to optimization.