Test Memory Bits against Accumulator

Bit is a dual-purpose instruction which performs operations against the accumulator and memory. It is usually used immediately preceding a conditional branch instruction

First it set's the n flag to reflect the value of the high bit of the data in memory and the v flag to the next-to-highest bit of that data.

For 8-bit processors n has the value of bit 7 and v the value of bit 6 of the memory location.

For 16-bit processors, when m=0, n has the value of bit 15 and v the value of bit 14 of the memory location.

Second it performs a logical AND of the memory and the accumulator. If the result is zero the z flag is set.

In both operations, the contents of the accumulator and memory are not modified.

Flags Affected
nTakes value of most significant bit of memory data, not in immediate addressing
vTakes value of the next-to-highest bit of memory data, not in immediate addressing
zSet if logical AND of memory & accumulator is zero, otherwise clear
SyntaxOpcode Available on: # of # of Addressing Mode
(hex) 6502 65C02 65816 bytes cycles
BIT #const89 x x 21 22 Immediate
BIT addr2C x x x 3 42 Absolute
BIT dp24 x x x 2 52, 3 Direct Page
BIT addr,X3C x x 3 42, 4 Absolute Indexed X
BIT dp,X34 x x 2 42, 3 Direct Page Indexed X


  1. 65816: Add 1 byte if m=0 (16-bit memory/accumulator)
  2. 658116: Add 1 cycle if m=0 (16-bit memory/accumulator)
  3. 65816: Add 1 cycle if low byte of Direct Page register is not 0
  4. Add 1 cycle if adding index crosses a page boundary

Last modified November 5, 2021: Add instruction categories (6b74ff9)