Shop OBEX P1 Docs P2 Docs Learn Events
How can you check a specific pin number inside of a cogs ina register in PASM? - Page 2 — Parallax Forums

How can you check a specific pin number inside of a cogs ina register in PASM?

2»

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2012-05-22 07:37
    turbosupra wrote: »
    x==y / x!=z := true
    x==y / x==z := false
    x!=y / x!=z := false
    x!=y / x==z := false
    If true means jump taken then it's wrong. If x <> y then the second compare isn't executed and can't affect the flags.
    cmp     x, y wz
            nop
    if_ne   jmp     #label
    
    Which means the branch is taken for x <> y. OTOH, if x == y the second compare is in fact executed and will override the z flag according to x ? z, in this case x <> z will allow the branch to be taken. Which gives us x <> y OR x <> z.
  • turbosupraturbosupra Posts: 1,088
    edited 2012-05-22 07:58
    Yes, true meant jmp #label

    This reminds me of a truth table, except I'm not sure I understand the outcome. Would another way of writing it be

    x<>y OR x==y/x<>z ?

    If so, this answers my question a few posts earlier of
    My question is, if x!=y, does it satisfy the if_ne also? If that is true, how would you handle that, with a jump, or is there something a little cleaner/universal like a break?
    I was wondering if the first comparison could affect the flag, if the second comparison was not evaluated. It sounds like you are saying yes and the new truth table would be:

    x==y / x!=z := true (jmp)
    x==y / x==z := false
    x!=y / x!=z := true (jmp)
    x!=y / x==z := true (jmp)
  • kuronekokuroneko Posts: 3,623
    edited 2012-05-22 17:18
    turbosupra wrote: »
    This reminds me of a truth table, except I'm not sure I understand the outcome. Would another way of writing it be

    x<>y OR x==y/x<>z ?
    Ah, I see. The slash counts as AND? If so this can be simplified. Let's say A stands for x <> y and B for x <> z, x == y would be /A. So we end up with A or /A and B. AND being stronger than OR gives us (A or /A) and (A or B). Which is the same as 1 and (A or B) or simply (A or B), i.e. x <> y OR x <> z.
    turbosupra wrote: »
    I was wondering if the first comparison could affect the flag, if the second comparison was not evaluated.
    Yes, any operation which has its flag modifiers (wz, wc) set will affect the flags unless the operation itself is disabled due to conditional execution (nop). In our case we simply have a cmp x, y wz. As this doesn't have any conditionals attached it will be executed and will affect the zero flag.
  • turbosupraturbosupra Posts: 1,088
    edited 2012-05-22 19:49
    Yes, but I didn't want to write "and" because we're using "or" and "and" as operators : )

    I see the algebraic simplification, thank you for that explanation. I also like the trick with the NOP, I can use that like a flag clear or comparison break.


    kuroneko wrote: »
    Ah, I see. The slash counts as AND? If so this can be simplified. Let's say A stands for x <> y and B for x <> z, x == y would be /A. So we end up with A or /A and B. AND being stronger than OR gives us (A or /A) and (A or B). Which is the same as 1 and (A or B) or simply (A or B), i.e. x <> y OR x <> z.


    Yes, any operation which has its flag modifiers (wz, wc) set will affect the flags unless the operation itself is disabled due to conditional execution (nop). In our case we simply have a cmp x, y wz. As this doesn't have any conditionals attached it will be executed and will affect the zero flag.
Sign In or Register to comment.