Shop OBEX P1 Docs P2 Docs Learn Events
Request for carry/borrow/overflow logic for add/sub/cmp/adds/subs/cmps — Parallax Forums

Request for carry/borrow/overflow logic for add/sub/cmp/adds/subs/cmps

Mark SwannMark Swann Posts: 124
edited 2007-10-16 23:27 in Propeller 1
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

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2007-10-16 18:44
    I should support that request especially for useful examples, to avoid that deSilva will be asked to provide them smile.gif

    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 smile.gif

    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!
  • Mark SwannMark Swann Posts: 124
    edited 2007-10-16 20:47
    I have attached a screen shot from a Morotola 68000 guide showing what I am looking for. The table shown in the screen shot shows boolean expressions for Carry, Zero and oVerflow.
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-16 23:24
    Good example! As the Prop is terribly simpler (just two flags, and Z is questionable in three or four cases only), this could be done in half an hour by person A and validated in the same time by person B.

    Q: Who is person A and who is person B smile.gif
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-10-16 23:27
    Jeff Martin from parallax has heard our plees. Don't know when we should expect to see something but something should come.

    Graham
Sign In or Register to comment.