Match the pairs by name, not by position
An expression over two globals needs two %hi/%lo pairs — and the scheduler shuffles them together. Here's sumPair, which returns gLeft + gRight:
lui t6, %hi(gLeft)
lui t7, %hi(gRight) # both uppers first…
lw t7, %lo(gRight)(t7) # …then the loads — gRight completes first!
lw t6, %lo(gLeft)(t6)
addu v0, t6, t7
jr ra
nop
Both luis are issued up front, then both loads — and the second global's load lands before the first's. The scheduler is stacking loads early so their latencies overlap; source order survives only in the final addu's operands. This is why the machinery lesson told you to match pairs by symbol name: in real listings the four address-building lines arrive in whatever order the pipeline likes best.
So the reading recipe for multi-global expressions:
- Group each
%lo with its %hi by name — ignore line order.
- Note which register each global's value ends up in.
- Read the arithmetic over those registers to reconstruct the expression.
The target combines two globals where the operation makes order matter. Step 3 is where the answer lives.
Your task
extern s32 gHome; and extern s32 gAway; are declared for you. Write func_8014d04c to reproduce the target assembly.