SUB[S]

If the S bit is set (SUBS), the N and Z flags are set according to the result, and the C and V flags are set as follows: C if the result generated a borrow (unsigned underflow); V if the result generated a signed overflow.

SUB is useful for basic addition. Use SBC to perform addition with the Carry flag considered.

If you should need to perform the subtraction in reverse (i.e. the shifted register/immediate minus register), look at RSB (Reverse SuBtract) and RSC (Reverse Subtract with Carry).

SUBS can be a useful loop counter without the need for a comparison operation. Code such as the following may be used: