Reputation: 2949
I am trying to figure out what this ARM assembly line does:
RSB r1, r2, r3, LSL #1
I am referring to RSB description from Keil help page but this example does not quite fit as it has more operands than the documentation.
Upvotes: 6
Views: 13035
Reputation: 6526
The RSB instruction is a Reverse SuBtract without carry.
The documentation indicates the syntax:
RSB{S}{cond} {Rd}, Rn, Operand2
The following usage can then be explained:
RSB r1, r2, r3, LSL #1
r3, LSL #1
is Operand2 → r3 register logical left-shifted by 1 bit So the operation uses r1, r2 and r3 registers as follows: r1 = (r3 << 1) - r2
Upvotes: 12
Reputation: 93117
The instruction RSB r1, r2, r3, LSL #1
shifts the contents of r3
left by one place, subtracts r2
and stores the result in r1
without setting flags. In pseudocode, it does this:
r1 = r3 + r3 - r2
Note that the third operand is a flexible operand comprising r3, LSL #1
. See this page for more details.
Upvotes: 3