The instruction picks itself
Subtracting a constant is the mirror of adding one:
0 sub r0, #20
2 bx lr
sub rD, #imm is rD = rD - imm, with the same eight-bit immediate field and the same lack of any separate load.
Here is the part worth noticing. This function does not subtract anything — it adds negative nine:
s32 backNine(s32 x) {
return x + -9;
}
and the compiler emits this:
0 sub r0, #9
2 bx lr
There is no "add a negative" instruction, so add and sub are chosen purely by the sign of the constant. Two different-looking pieces of C collapse to the same instruction, which means the assembly cannot tell you which one the original author wrote. Matching is about instructions, so either is correct — and you will meet this ambiguity constantly. Write whichever reads more naturally.
Your task
Write decay, taking an s32 x, to reproduce the target assembly.