AND                  "AND" memory with accumulator                    AND
  Operation:  A /\ M -> A                               N V - B D I Z C
                                                        / . . . . . / .
  +----------------+-----------------------+---------+---------+----------+
  | Addressing Mode| Assembly Language Form| OP CODE |No. Bytes|No. Cycles|
  +----------------+-----------------------+---------+---------+----------+
  |  Immediate     |   AND #$FF            |   $29   |    2    |    2     |
  |  ZeroPage      |   AND $FF             |   $25   |    2    |    3     |
  |  ZeroPage,X    |   AND $FF,X           |   $35   |    2    |    4     |
  |  Absolute      |   AND $FFFF           |   $2D   |    3    |    4     |
  |  Absolute,X    |   AND $FFFF,X         |   $3D   |    3    |    4*    |
  |  Absolute,Y    |   AND $FFFF,Y         |   $39   |    3    |    4*    |
  |  (Indirect,X)  |   AND ($FF,X)         |   $21   |    2    |    6     |
  |  (Indirect),Y  |   AND ($FF),Y         |   $31   |    2    |    5*    |
  +----------------+-----------------------+---------+---------+----------+
  * Add 1 if page boundary is crossed.
  For penalty cycles on the 65816, check the desired addressing mode.
 65816 Extensions:
  +----------------+-----------------------+---------+---------+----------+
  | Addressing Mode| Assembly Language Form| OP CODE |No. Bytes|No. Cycles|
  +----------------+-----------------------+---------+---------+----------+
  | AbsoluteLong   |   AND $FFFFFF         |   $2F   |    4    |     5    |
  | AbsoluteLong,X |   AND $FFFFFF,X       |   $3F   |    4    |     5    |
  | (Indirect)     |   AND ($FF)           |   $32   |    2    |     5    |
  | [Indirect Long]|   AND [$FF]           |   $27   |    2    |     6    |
  | [Ind.Long],Y   |   AND [$FF],Y         |   $37   |    2    |     6    |
  | Relative,S     |   AND $FF,S           |   $23   |    2    |     4    |
  | (Indirect,S),Y |   AND ($FF,S),Y       |   $33   |    2    |     7    |
  +----------------+-----------------------+---------+---------+----------+
What it does: Logical ANDS the byte in memory with the byte in the Accumulator. The result is left in the Accumulator. All bits in both bytes are compared, and if both bits are 1, the result is 1. If either or both bits are 0, the result is 0.
Major uses: Most of the time, AND is used to turn bits off. Let's say that you are pulling in numbers higher than 128 (10000000 and higher) and you want to "unshift" them and print them as lowercase letters. You can then put a zero into the seventh bit of your "mask" and then AND the mask with the number being unshifted:
LDA ? (test number) AND #$7F (01111111)
(If either bit is 0, the result will be 0. So the seventh bit of the test number is turned off here and all the other bits in the test number are unaffected.)