BIT             BIT Test bits in memory with accumulator              BIT

  Operation:  A /\ M -> Z, M7 -> N, M6 -> V             N V - B D I Z C
                                                        M7M6. . . . / .
  Bit 6 and 7 are transferred to the status register.
  If the result of A /\ M is zero then Z = 1, otherwise Z=0.

  +----------------+-----------------------+---------+---------+----------+
  | Addressing Mode| Assembly Language Form| OP CODE |No. Bytes|No. Cycles|
  +----------------+-----------------------+---------+---------+----------+
  |  ZeroPage      |   BIT $FF             |   $24   |    2    |    3     |
  |  Absolute      |   BIT $FFFF           |   $2C   |    3    |    4     |
  +----------------+-----------------------+---------+---------+----------+
  For penalty cycles on the 65816, check the desired addressing mode.

 65816 Extensions:

  +----------------+-----------------------+---------+---------+----------+
  | Addressing Mode| Assembly Language Form| OP CODE |No. Bytes|No. Cycles|
  +----------------+-----------------------+---------+---------+----------+
  | Immediate      |   BIT #$FF            |   $89   |    2    |    2     |
  | Direct Page,X  |   BIT $FF,X           |   $34   |    2    |    3     |
  | Absolute,X     |   BIT $FFFF,X         |   $3C   |    3    |    4     |
  +----------------+-----------------------+---------+---------+----------+

What it does: Tests the bits in the byte in memory against the bits in the byte held in the Accumulator. The bytes (memory and Accumulator) are unaffected. BIT merely sets flags. The Z flag is set as if an Accumulator AND memory had been performed. The V flag and the N flag receive copies of the sixth and seventh bits of the tested number.

Major uses: Although BIT has the advantage of not having any effect on the tested numbers, it is infrequently used because you cannot employ the Immediate addressing mode with it. Other tests (CMP and AND, for example) can be used instead.