Arm Community
Site
Search
User
Site
Search
User
Groups
Research Collaboration and Enablement
DesignStart
Education Hub
Innovation
Open Source Software and Platforms
Forums
AI and ML forum
Architectures and Processors forum
Arm Development Platforms forum
Arm Development Studio forum
Arm Virtual Hardware forum
Automotive forum
Compilers and Libraries forum
Graphics, Gaming, and VR forum
High Performance Computing (HPC) forum
Infrastructure Solutions forum
Internet of Things (IoT) forum
Keil forum
Morello Forum
Operating Systems forum
SoC Design and Simulation forum
中文社区论区
Blogs
AI and ML blog
Announcements
Architectures and Processors blog
Automotive blog
Graphics, Gaming, and VR blog
High Performance Computing (HPC) blog
Infrastructure Solutions blog
Innovation blog
Internet of Things (IoT) blog
Operating Systems blog
Research Articles
SoC Design and Simulation blog
Tools, Software and IDEs blog
中文社区博客
Support
Arm Support Services
Documentation
Downloads
Training
Arm Approved program
Arm Design Reviews
Community Help
More
Cancel
Support forums
Arm Development Studio forum
Carry-Bit vs. Documentation
Jump...
Cancel
Locked
Locked
Replies
2 replies
Subscribers
121 subscribers
Views
2463 views
Users
0 members are here
Options
Share
More actions
Cancel
Related
How was your experience today?
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
Offline
Rene Henke
over 9 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é
Offline
Simon Craske
over 9 years ago
Note: This was originally posted on 27th June 2012 at
http://forums.arm.com
Subtract / compare can produce all combinations of flags except negative-zero (N=1, Z=1) and (N=0, C=0, V=1);
however, the combinations of (N=0, C=0, V=0, Z=1) and (N=0, C=1, V=1, Z=1) require the use of SBCS/RSCS (subtract with carry).
A simple subtract of the value one from value minus-one will produce a negative result (minus-two) and set the carry flag (not borrow).
In summary, I don't think the documentation you are referring to is definitive.
hth
s.
Cancel
Up
0
Down
Cancel
Offline
Joseph Yiu
over 9 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
Up
0
Down
Cancel