Reading a three-operand add
Thumb's register add takes three operands: add Rd, Rs, Rn, meaning Rd = Rs + Rn. Destination up front, the two sources trailing behind. A function that returns the sum of its second and third arguments, for instance, compiles to exactly one of these:
add r0, r1, r2
bx lr
There the two sources are r1 and r2 — the second and third arguments — and the result lands in r0, ready to return.
Your exercise takes only two ints. The calling convention lines them up left-to-right in r0 and r1. So go stare at the target for a second: what expression over those two would agbcc boil down to a single add that touches both of them?
Your task
Write add2, taking two ints, to reproduce the target assembly.