While doing my homework on ARM controllers and assembly programming, I stumbled upon a confusing question.

So here's the line of code which I don't understand (there are other codes before and after this line):

ADDS r0, r5, r6

where r5 is 0x20408624 and r6 is 0x42680402.

The question asks me to explain the difference in the carry bit of xPSR before and after executing the ADDS operation.

According to the software I am using, C is 1 before ADDS, and 0 after. I understand why it's 0 after, but why is it 1 before? Could it be related to a previous instruction that has altered C?

  • 2
    \$\begingroup\$ It must be left like that from a previous instruction. Only you know what they were. If I was experimenting in asm, I would use another inst to clear the flag before the add, and verify it made no difference. \$\endgroup\$
    – user16324
    Commented Sep 25, 2020 at 11:30

1 Answer 1


Yes you are right, it is set to some state according to some result of some instruction executed previously at some point, and ADDS instruction updates the flags so they show the result of the addition it just performed.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.