I don't understand SBC
and RSC
ARM instructions
I know that both deal with the carry flag (C)
I think it makes sense adding the result with the carry (ADC
) like:
ADC r1, r2, r3 @ r1 = r2 + r3 + Carry
But subtracting/reverse subtracting with the carry... I can't understand what is happening :(
Can you guys give me an example using SBC
and RSC
?
Given two's complement, subtraction can just be transformed into addition:
which makes it easier to consider how the carry flag is set in that situation, i.e. by
subs
:Hence why the value of the C flag is nB ("not borrow"), so
sbc
as "subtract with carry" means "subtract with not borrow", or in other words: