llms.txt
Compare with other sites' llms.txt files →# Decomp Academy
> Decomp Academy is a free, interactive course that teaches matching decompilation of retro games: read the original assembly, write C, and the real period compiler grades it byte for byte. Courses cover GameCube (PowerPC, Metrowerks CodeWarrior) and Game Boy Advance (ARM/Thumb, agbcc).
Decomp Academy teaches "matching decompilation": you read the assembly the retail compiler produced, write C, and the original compiler compiles and diffs your code against the target instruction by instruction. When every byte matches, the function is solved. The curriculum takes you from never having read a register to matching real functions from games like Star Fox Adventures and Klonoa: Empire of Dreams.
- Audience: programmers learning reverse engineering and decompilation, contributors to retro-game decompilation projects, and anyone curious how C compiles down to machine code.
- Format: 755 hands-on lessons across 3 courses, in the browser, free, with no signup required to start.
- Topics: PowerPC and ARM/Thumb assembly, application binary interfaces, compiler code generation, integer/float/bitwise idioms, stack frames, globals, the optimizer, and complete real-game functions.
## Key pages
- [Start the course](https://decomp-academy.dev/courses/gamecube-c/lesson/foundations-what-is-matching): the first lesson, from zero.
- [Playground](https://decomp-academy.dev/playground): compile arbitrary C with MWCC GC/2.0 and inspect the assembly it produces.
- [Glossary](https://decomp-academy.dev/glossary): definitions of the PowerPC, ABI, and compiler terms used throughout.
## Curriculum
### GameCube — Decompile GameCube PowerPC assembly back into byte-matching C, graded live by the real Metrowerks CodeWarrior GC/2.0 compiler.
#### Warm-up — Learn to read the machine
##### Foundations — What decompilation is, PowerPC registers, and reading MWCC output.
- [What Matching Decompilation Is](https://decomp-academy.dev/courses/gamecube-c/lesson/foundations-what-is-matching) — matching, toolchain, workflow, mental-model
- [How to Read PowerPC Assembly](https://decomp-academy.dev/courses/gamecube-c/lesson/foundations-reading-assembly) — assembly, registers, instructions, mental-model
- [Your First Match](https://decomp-academy.dev/courses/gamecube-c/lesson/foundations-welcome) — registers, return-value, workflow
- [Arguments Live in Registers Too](https://decomp-academy.dev/courses/gamecube-c/lesson/foundations-identity) — registers, calling-convention
- [Immediates: Math With Constants](https://decomp-academy.dev/courses/gamecube-c/lesson/foundations-immediate) — arithmetic, immediates
- [Subtracting a Constant](https://decomp-academy.dev/courses/gamecube-c/lesson/foundations-subtract-const) — arithmetic, immediates
- [Multiply by a Small Constant](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-mul-const) — strength-reduction, immediates
- [Dividing by a Constant](https://decomp-academy.dev/courses/gamecube-c/lesson/foundations-div-const) — arithmetic, divide
- [Negation and the Zero Register](https://decomp-academy.dev/courses/gamecube-c/lesson/foundations-negate) — arithmetic, registers
##### Reading Signatures — No more starter functions — derive the arguments and return type yourself.
- [The Band-Aid Comes Off](https://decomp-academy.dev/courses/gamecube-c/lesson/signatures-bandaid) — calling-convention, workflow, mental-model
- [Counting the Arguments](https://decomp-academy.dev/courses/gamecube-c/lesson/signatures-counting-args) — calling-convention, registers, arguments
- [Read an Argument Off the Registers](https://decomp-academy.dev/courses/gamecube-c/lesson/signatures-arg-registers) — calling-convention, registers, arguments
- [Count Them Yourself](https://decomp-academy.dev/courses/gamecube-c/lesson/signatures-derive) — calling-convention, arguments, arithmetic
#### Core idioms — Every shape C compiles into
##### Integer Arithmetic — Add, subtract, multiply, divide, immediates and the bit-twiddling idioms.
- [On to Arithmetic](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-intro) — arithmetic, mental-model
- [Adding Two Registers](https://decomp-academy.dev/courses/gamecube-c/lesson/foundations-add) — registers, arithmetic
- [Subtraction Reverses Its Operands](https://decomp-academy.dev/courses/gamecube-c/lesson/foundations-subtract) — arithmetic, operand-order
- [An Add Then a Subtract](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-add-sub) — arithmetic, chaining, operand-order
- [Two Adds, Reassociated](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-two-adds) — arithmetic, chaining, reassociation
- [A Subtract Then an Add](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-sub-add) — arithmetic, chaining, operand-order
- [A Three-Instruction Chain](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-add-sub-add) — arithmetic, chaining, operand-order
- [Multiplying Two Registers](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-mul) — arithmetic, multiply
- [Multiply by a Power of Two](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-mul-const-pow2) — strength-reduction, shifts
- [An Affine Expression](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-affine) — arithmetic, strength-reduction, instruction-selection
- [Unsigned Divide by a Power of Two](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-div-pow2-unsigned) — strength-reduction, shifts, unsigned
- [Signed Divide by a Power of Two](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-div-pow2-signed) — strength-reduction, shifts, signed, rounding
- [Division Without a Divide](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-reciprocal-divide) — strength-reduction, divide, optimization
- [Real Division](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-div-var) — arithmetic, divide, signed
- [Modulo Has No Instruction](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-mod) — arithmetic, modulo
- [Multiply Then Add](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-mul-add) — arithmetic, multiplication, chaining
- [Precedence Changes the Order](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-add-mul) — arithmetic, multiplication, precedence, chaining
- [Two Products, Subtracted](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-two-products) — arithmetic, multiplication, chaining, operand-order
- [A Three-Instruction Mixed Chain](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-mul-add-sub) — arithmetic, multiplication, chaining, operand-order
- [When a Multiply Is a Shift](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-scale-sum) — arithmetic, multiplication, strength-reduction, chaining
- [A Shift Inside a Mixed Chain](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-scale-chain) — arithmetic, multiplication, strength-reduction, chaining
- [Divide Then Add](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-div-add) — arithmetic, division, chaining
- [When a Divide Is a Shift](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-shrink-sum) — arithmetic, division, strength-reduction, chaining
- [A Shift-Divide in a Chain](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-shrink-chain) — arithmetic, division, strength-reduction, chaining
- [Divide and Multiply, Then Subtract](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-div-sub-mul) — arithmetic, division, multiplication, chaining, operand-order
- [Multiply and Divide Combined](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-mul-add-div) — arithmetic, multiplication, division, chaining, operand-order
- [All Four Arithmetic Operators](https://decomp-academy.dev/courses/gamecube-c/lesson/arithmetic-all-four-ops) — arithmetic, multiplication, division, chaining, operand-order
##### Bitwise & Shifts — AND/OR/XOR, masks, shifts, and the rlwinm family MWCC loves.
- [Masking Bits With AND](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-and-mask) — bitwise, and, masks
- [Combining Bits With OR](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-or) — bitwise, or, immediates
- [Flipping Bits With XOR](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-xor) — bitwise, xor, immediates
- [Setting a Single Flag Bit](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-set-flag) — bitwise, or, flags
- [Clearing a Bit: The rlwinm Surprise](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-clear-flag) — bitwise, and, rlwinm, mwcc-idiom
- [Testing Whether a Bit Is Set](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-test-bit) — bitwise, and, rlwinm, masks
- [Shifting Left by a Constant](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-shift-left) — bitwise, shifts, rlwinm
- [Logical Right Shift (Unsigned)](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-shift-right-unsigned) — bitwise, shifts, unsigned, srwi
- [Arithmetic Right Shift (Signed)](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-shift-right-signed) — bitwise, shifts, signed, srawi
- [Shifting by a Variable Amount](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-shift-variable) — bitwise, shifts, variable-shift, slw
- [Extracting a Bitfield in One rlwinm](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-extract-field) — bitwise, rlwinm, bitfields, instruction-selection
- [Packing Two Values with a Shift and OR](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-shift-or-pack) — bitwise, shift, or, chaining
- [Merging Two Fields: rlwinm + rlwimi](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-merge-fields) — bitwise, and, or, rlwinm, rlwimi, mwcc-idiom
- [Chaining XOR Across Three Values](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-xor-chain) — bitwise, xor, chaining
- [Bit Select (Mux): AND, ANDC, OR](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-bit-select) — bitwise, and, andc, or, chaining
- [Capstone: Pack Three Values into One Word](https://decomp-academy.dev/courses/gamecube-c/lesson/bitwise-pack-three) — bitwise, shift, or, chaining, capstone
##### Control Flow — if/else, ternaries, switch, and the all-important signed-vs-unsigned compare.
- [Returning a Comparison as a Bool](https://decomp-academy.dev/courses/gamecube-c/lesson/control-eq-bool) — comparison, boolean, idiom
- [Not-Equal Is Its Own Idiom](https://decomp-academy.dev/courses/gamecube-c/lesson/control-ne-bool) — comparison, boolean, idiom
- [If / Else: The Compare Feeds a Branch](https://decomp-academy.dev/courses/gamecube-c/lesson/control-if-else) — if-else, comparison, branch
- [Two's Complement, srawi, and andc by Hand](https://decomp-academy.dev/courses/gamecube-c/lesson/control-sign-masks) — twos-complement, srawi, andc, bitwise, sign-mask
- [Clamping to Zero, Branchlessly](https://decomp-academy.dev/courses/gamecube-c/lesson/control-clamp-low) — if, clamp, branchless, idiom
- [Signed Compare: cmpw](https://decomp-academy.dev/courses/gamecube-c/lesson/control-cmp-signed) — comparison, signed, branch, types
- [Unsigned Compare: cmplw](https://decomp-academy.dev/courses/gamecube-c/lesson/control-cmp-unsigned) — comparison, unsigned, branch, types
- [Comparing Against a Constant: cmpwi vs cmplwi](https://decomp-academy.dev/courses/gamecube-c/lesson/control-cmp-immediate) — comparison, immediates, signed, unsigned, types
- [The Guard Clause / Early Return](https://decomp-academy.dev/courses/gamecube-c/lesson/control-guard) — if, early-return, branch, guard
- [Ternary Max](https://decomp-academy.dev/courses/gamecube-c/lesson/control-ternary-max) — ternary, comparison, select
- [Ternary Min](https://decomp-academy.dev/courses/gamecube-c/lesson/control-ternary-min) — ternary, comparison, select
- [Short-Circuit && and ||](https://decomp-academy.dev/courses/gamecube-c/lesson/control-short-circuit) — boolean, short-circuit, branch, logic
- [Switch: The Compare Chain](https://decomp-academy.dev/courses/gamecube-c/lesson/control-switch) — switch, branch, comparison, control-flow
- [Clamping Between Two Bounds](https://decomp-academy.dev/courses/gamecube-c/lesson/control-clamp-range) — clamp, if, branch, combining
- [The if / else-if Ladder](https://decomp-academy.dev/courses/gamecube-c/lesson/control-nested-ladder) — if-else, nested, branch, combining
- [A Range Test with &&](https://decomp-academy.dev/courses/gamecube-c/lesson/control-range-and) — short-circuit, range, boolean, combining
- [Rejecting Out-of-Range with ||](https://decomp-academy.dev/courses/gamecube-c/lesson/control-reject-or) — short-circuit, range, boolean, combining
- [A Multi-Condition Guard](https://decomp-academy.dev/courses/gamecube-c/lesson/control-guard-or) — guard, short-circuit, early-return, combining
- [Capstone: A Guarded, Clamped Update](https://decomp-academy.dev/courses/gamecube-c/lesson/control-capstone-clamp-step) — capstone, guard, clamp, combining, branch
##### Loops — for, while, do-while, induction variables and counted loops.
- [The Anatomy of a Counted Loop](https://decomp-academy.dev/courses/gamecube-c/lesson/loops-for-sum) — for-loop, induction-variable, control-flow
- [While Is the Same Loop](https://decomp-academy.dev/courses/gamecube-c/lesson/loops-while-equivalence) — while-loop, for-loop, control-flow
- [Do-While: The Tightest Loop](https://decomp-academy.dev/courses/gamecube-c/lesson/loops-do-while) — do-while, control-flow, branch-elimination
- [Counting Down Is Cheaper](https://decomp-academy.dev/courses/gamecube-c/lesson/loops-countdown) — countdown, induction-variable, immediates
- [Walking an Array by Index](https://decomp-academy.dev/courses/gamecube-c/lesson/loops-array-sum) — arrays, indexed-load, addressing
- [Finding the Maximum](https://decomp-academy.dev/courses/gamecube-c/lesson/loops-array-max) — arrays, ctr-loop, conditional-update
- [Walking a Pointer to a Sentinel](https://decomp-academy.dev/courses/gamecube-c/lesson/loops-strlen) — pointers, sentinel, byte-load
- [Breaking Out Early](https://decomp-academy.dev/courses/gamecube-c/lesson/loops-break) — break, early-exit, linear-search
- [A Mental Model: The Five Parts of a Loop](https://decomp-academy.dev/courses/gamecube-c/lesson/loops-anatomy-model) — control-flow, break, continue, mental-model
- [Strength-Reduced Induction](https://decomp-academy.dev/courses/gamecube-c/lesson/loops-strength-reduction) — strength-reduction, induction-variable, pointers
- [A Loop With More Work Inside](https://decomp-academy.dev/courses/gamecube-c/lesson/loops-weighted-sum) — arrays, induction-variable, involved-body
- [Nested Loops](https://decomp-academy.dev/courses/gamecube-c/lesson/loops-nested) — nested-loops, multiply, control-flow
- [Nesting Over a 2-D Array](https://decomp-academy.dev/courses/gamecube-c/lesson/loops-grid-sum) — nested-loops, arrays, row-major, indexed-load
- [When the Inner Bound Follows the Outer](https://decomp-academy.dev/courses/gamecube-c/lesson/loops-triangular) — nested-loops, triangular, control-flow
- [Capstone: Reading Nested Array Loops](https://decomp-academy.dev/courses/gamecube-c/lesson/loops-inversions) — nested-loops, triangular, arrays, conditional-update, capstone
##### Types & Width — u8/s8/u16/s16 loads, sign vs zero extension, and width-driven matching, building up to mixed-width and mixed-sign expressions.
- [Loading a Byte](https://decomp-academy.dev/courses/gamecube-c/lesson/types-load-u8) — loads, unsigned, zero-extension
- [Loading a Halfword](https://decomp-academy.dev/courses/gamecube-c/lesson/types-load-u16) — loads, unsigned, zero-extension
- [Signed Loads Sign-Extend](https://decomp-academy.dev/courses/gamecube-c/lesson/types-load-signed) — loads, signed, sign-extension
- [Storing a Byte Truncates](https://decomp-academy.dev/courses/gamecube-c/lesson/types-store-byte) — stores, truncation
- [Storing a Halfword](https://decomp-academy.dev/courses/gamecube-c/lesson/types-store-half) — stores, truncation
- [u8, Not char (The Spurious extsb)](https://decomp-academy.dev/courses/gamecube-c/lesson/types-u8-not-char) — signed, char, sign-extension, matching-idiom
- [Widening: Zero vs Sign Extend](https://decomp-academy.dev/courses/gamecube-c/lesson/types-widen-zero-vs-sign) — widening, sign-extension, zero-extension
- [Truncating With a Mask](https://decomp-academy.dev/courses/gamecube-c/lesson/types-truncate-mask) — truncation, masking, rlwinm
- [Casts That Sign-Extend](https://decomp-academy.dev/courses/gamecube-c/lesson/types-explicit-cast) — casts, sign-extension, extsb, extsh
- [Casting Between Signed Widths](https://decomp-academy.dev/courses/gamecube-c/lesson/types-cast-between-signed) — casts, signed, sign-extension
- [The Compare Opcode Follows the Type](https://decomp-academy.dev/courses/gamecube-c/lesson/types-compare-width) — comparison, signed, unsigned, branch
- [Bumping a Byte Counter](https://decomp-academy.dev/courses/gamecube-c/lesson/types-counter-increment) — loads, stores, read-modify-write, u8
- [Read, Scale, Truncate](https://decomp-academy.dev/courses/gamecube-c/lesson/types-rmw-scale) — loads, stores, read-modify-write, truncation, u8
- [A Signed Halfword Read-Modify-Write](https://decomp-academy.dev/courses/gamecube-c/lesson/types-rmw-half) — loads, stores, read-modify-write, signed, sign-extension
- [Combining Two Widths](https://decomp-academy.dev/courses/gamecube-c/lesson/types-mix-widths) — widening, zero-extension, sign-extension, mixed-width
- [Mixed Signedness in One Expression](https://decomp-academy.dev/courses/gamecube-c/lesson/types-mix-signs) — widening, zero-extension, sign-extension, mixed-signedness, operand-order
- [Capstone: Widths and Signs in One Function](https://decomp-academy.dev/courses/gamecube-c/lesson/types-capstone) — widening, zero-extension, sign-extension, mixed-width, mixed-signedness, chaining
##### Pointers & Memory — Loads and stores, addressing modes, pointer arithmetic and arrays.
- [Dereferencing a Pointer](https://decomp-academy.dev/courses/gamecube-c/lesson/pointers-deref) — loads, pointers, memory
- [Storing Through a Pointer](https://decomp-academy.dev/courses/gamecube-c/lesson/pointers-store) — stores, pointers, memory
- [A Constant Index Becomes a Displacement](https://decomp-academy.dev/courses/gamecube-c/lesson/pointers-index-const) — loads, addressing, arrays
- [Writing at a Constant Index](https://decomp-academy.dev/courses/gamecube-c/lesson/pointers-store-index-const) — stores, addressing, arrays
- [Pointer Arithmetic Is Scaled](https://decomp-academy.dev/courses/gamecube-c/lesson/pointers-arith) — pointers, arithmetic, scaling
- [A Variable Index Needs Scaling Then Indexing](https://decomp-academy.dev/courses/gamecube-c/lesson/pointers-index-var) — loads, indexed-addressing, scaling
- [Byte Arrays Need No Shift](https://decomp-academy.dev/courses/gamecube-c/lesson/pointers-u8-array) — loads, indexed-addressing, u8
- [Halfword Arrays Shift by One](https://decomp-academy.dev/courses/gamecube-c/lesson/pointers-u16-array) — loads, indexed-addressing, u16, sign
- [Walking a String](https://decomp-academy.dev/courses/gamecube-c/lesson/pointers-strlen) — loops, pointers, u8
- [Comparing Two Pointers](https://decomp-academy.dev/courses/gamecube-c/lesson/pointers-compare) — pointers, comparison, boolean
- [Guarding Against NULL](https://decomp-academy.dev/courses/gamecube-c/lesson/pointers-null-check) — pointers, branches, null
- [Swapping Through Pointers](https://decomp-academy.dev/courses/gamecube-c/lesson/pointers-swap) — loads, stores, pointers
- [Reading Two Elements and Combining Them](https://decomp-academy.dev/courses/gamecube-c/lesson/pointers-sum-two) — loads, arrays, chaining
- [Scaling One Element Before Combining](https://decomp-academy.dev/courses/gamecube-