Espozo wrote:Sorry about this, but I was going to hold off this question so I didn't sound stupid, but I don't care. The bit instruction can be used as an "and" and a "cmp", so you only use one instruction instead of two? It seems like that's what's happening in psychopathicteen's code.
I didn't look at his code, but just think about what the instruction does for a sec. CMP tests values, BIT tests 'bits'. You can test one bit, or more than one bit. You don't need a compare instruction, because you're only testing if 1 or more bits are
zero or
not zero. And those bits don't need to be next to each other either, etc. You can do this without BIT, but you would have to AND with Acc first, which means you've destroyed the original contents of Acc. A byte (or word) might have both data and flags in the value. This is one way to test and branch as needed. Or a byte/word might just be a series of state flags, and you test them in a sequential fashion or whatever (i.e. you don't want to keep loading isolating bits to test with AND).
The N/V flags as a different aspect of it though. You can use the BIT instruction to basically test these two bits of a byte in memory, without loading anything into a register. It saves some cycles. If you use an indexing mode, you can exploit this further (you have fast/instance access to whether the data/struct of an array is valid/applicable or not, using an auxiliary list/array/table/etc).
93143: IIRC, there are technically two versions of the 65C02 from WDC. One is the original processor, and the other is the 65C02 MCU they later developed. The later MCU is supposed to have taken the new instructions that Rockwell added to their own R65C02S (sometimes listed as 65CS02, which is the branch the 6280 is from).