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.
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:
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 . Which is the same as 1 and (A or or simply (A or , i.e. x <> y OR x <> z.
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.
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.
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 . Which is the same as 1 and (A or or simply (A or , 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.
Comments
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 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)
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.
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.