Subtract with carry (source code)

= Subtract with carry

With the <ARM architecture family>'s no-borrow convention, <subtract with carry> forms $X-Y-(1-C_{\rm in})$. The same <adder> used for addition can form $X+(2^n-1-Y)+C_{\rm in}$. If its output is $Z+2^nC_{\rm out}$, rearranging proves $X-Y-(1-C_{\rm in})=Z-2^n(1-C_{\rm out})$. Thus complementing the second operand implements both the result and the correctly chained borrow information.<Thumb 16-bit instruction set quick reference by Arm>[Page 1, Subtract with carry]{ref}