Arm Community
Site
Search
User
Site
Search
User
Support forums
Arm Development Studio forum
Carry-Bit vs. Documentation
Jump...
Cancel
Locked
Locked
Replies
2 replies
Subscribers
118 subscribers
Views
3112 views
Users
0 members are here
Options
Share
More actions
Cancel
Related
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion
Carry-Bit vs. Documentation
Rene Henke
over 12 years ago
Note: This was originally posted on 27th June 2012 at
http://forums.arm.com
Hello,
in every documentation I found something like
"A carry occurs (..)
, if the result of a subtraction is positive, (...)."
If I understand this right after a substraction (this is important) with a negativ (N = 1) result there can´t occur a carry, isn´t it?
For examble if I try
0x7FFF FFFF - 0xFFFF FFFF = 0x8000 0000
The CPSR are set like this NzcVqIFt_SVC => N = 1, C = 0, V = 1
After a substraction - Carry (borrow) = 0 means we have a borrow! Right?
So a carry occurs but the result is negativ!
Is the documentation right and complete? Or is there something missing or I´m completely wrong?
Thanks
René
Parents
Joseph Yiu
over 12 years ago
Note: This was originally posted on 27th June 2012 at
http://forums.arm.com
If you are talking about my Cortex-M3 book, look like it is my fault... I didn't double check all cases.
So the "If the result of a subtraction is positive or zero" text is incorrect. Sorry.
(This might originated from RealView Compilation Tools Assembler Guide...including latest DS-5 document. I will log a defect on this.)
I can't find the definition in the ARMv7-M architecture reference manual either, but got this in ARMv6-M architecture reference manual:
C is set in one of four ways:
For an addition, including the comparison instruction CMN, C is set to 1 if the addition produced a carry (that is, an unsigned overflow), and to 0 otherwise.
For a subtraction, including the comparison instruction CMP, C is set to 0 if the subtraction produced a borrow (that is, an unsigned underflow), and to 1 otherwise.
For non-addition/subtractions that incorporate a shift operation, C is set to the last bit shifted out of the value by the shifter.
For other non-addition/subtractions, C is normally left unchanged (but see the individual instruction descriptions for any special cases).
regards,
Joseph
Cancel
Vote up
0
Vote down
Cancel
Reply
Joseph Yiu
over 12 years ago
Note: This was originally posted on 27th June 2012 at
http://forums.arm.com
If you are talking about my Cortex-M3 book, look like it is my fault... I didn't double check all cases.
So the "If the result of a subtraction is positive or zero" text is incorrect. Sorry.
(This might originated from RealView Compilation Tools Assembler Guide...including latest DS-5 document. I will log a defect on this.)
I can't find the definition in the ARMv7-M architecture reference manual either, but got this in ARMv6-M architecture reference manual:
C is set in one of four ways:
For an addition, including the comparison instruction CMN, C is set to 1 if the addition produced a carry (that is, an unsigned overflow), and to 0 otherwise.
For a subtraction, including the comparison instruction CMP, C is set to 0 if the subtraction produced a borrow (that is, an unsigned underflow), and to 1 otherwise.
For non-addition/subtractions that incorporate a shift operation, C is set to the last bit shifted out of the value by the shifter.
For other non-addition/subtractions, C is normally left unchanged (but see the individual instruction descriptions for any special cases).
regards,
Joseph
Cancel
Vote up
0
Vote down
Cancel
Children
No data