= Solution
A <subtract with carry> instruction consumes the \i[no-borrow] <carry flag>. Its arithmetic is \b[$Z=X-Y-(1-C_{\mathrm{in}})\pmod{2^{32}}$]. Hence a low-limb `subs` followed immediately by a high-limb `sbcs` propagates exactly the low subtraction's borrow.
For example, with the same limb assignment as in (c):
``
subs r0, r0, r2
sbcs r1, r1, r3
``
It uses an ordinary 32-bit <adder> by complementing every <bit> of the subtrahend and adding the incoming <arithmetic carry>. For $M=2^{32}$, the unreduced <adder> sum is
$$
X+(M-1-Y)+C_{\mathrm{in}}.
$$
If this is $Z+MC_{\mathrm{out}}$, rearrangement gives $X-Y-(1-C_{\mathrm{in}})=Z-M(1-C_{\mathrm{out}})$. Thus both the result and outgoing no-borrow flag have the required meanings. With incoming <arithmetic carry> one this becomes ordinary subtraction.<Thumb 16-bit instruction set quick reference by Arm>[Page 1, Add with carry and Subtract with carry: subtraction subtracts NOT C-bit]{ref}
Back to article page