Request for carry/borrow/overflow logic for add/sub/cmp/adds/subs/cmps
Mark Swann
Posts: 124
Is there any documentation descibing the carry/borrow/overflow logic that defines the carry flag in the add/sub/cmp/adds/subs/cmps instructions.
What I am looking for is some simple boolean statements or logic diagrams to help me understand what Carry means and, hence, how to use it in all the different signed and unsigned instructions.
Thanks
What I am looking for is some simple boolean statements or logic diagrams to help me understand what Carry means and, hence, how to use it in all the different signed and unsigned instructions.
Thanks
Comments
On the other hand the rules are extremely simple, and just need you get rid of your prejudices of what you think the flags SHOULD do
CMP a,b and CMPS a,b should be extremly simple: C means a<b
SUB and ADD is simple as well: C means OVERFLOW, which means that the result is not what you are expecting, but rather wrapped around 2^32
With SUBS and ADDS the carry is tricky and indicates an OVERFLOW of the signed value. Whether this is a borrow or carry depends on the sign of the (overflowed) result. Anyone preparing examples should by all means care for ADDSX and SUBSX.
Zero is always as expected!
Q: Who is person A and who is person B
Graham