Hi hl,
> Yes. Any bit set after AND mask applied will result in a non-zero
> result: This is Z=0. I think another counter-intuitive effect is that
> the flag is named ZERO, but if it applies, the bit is ONE. In contrast:
> the NEGATIVE bit is set if the number is negative, i.e. bit is ONE -
> this is what was one would expect: it repesents the real situation.
I asked my brother about this today. He's a senior C guru and I asked
him about the logic behind this. He knows a lot about bit manipulation
stuff, though he is not familiar with the 65xx CPU series in
particular. He explained the logic behind this to me and why he would
see it as perfectly logical that the Z bit appears reversed to
intuition because it's mathematically correct. I didn't get that at
first and had to think about it. And I'm not sure I fully understood
his explanations completely but I know now what the BIT instruction
does and that's what counts for me. :-)
As a mnemonic I just take it that (given true=0 and false=1), the Z bit
is either true or false, with exactly these values. This is intuitive
enough for me.
> The BIT instruction IMHO was actually not intended to check for multiple bits.
that was the confusing part for me. :) I also couldn't find it being
mentioned in any of the instruction set descriptions available on the
net. The all only mention the "and" part and that bit N, V and Z get
set accordingly, but don't mention how the Z bit is actually processed.
That's why I asked because I was confused at my own test results.
--
cul8er
Paul
paul.f...@gmx.net