btst

Test a bit

Tests the bit in the second operand numbered by the first operand and sets Z to the inverse of its value.

Sizes .b .l

XNZVC ––●––
  • ● depends on the result
  • – not changed

Forms

Operands

<ea>
An operand using one of the addressing modes listed for this form. The list determines whether it can be a register, memory or an immediate value. With opt p=68020, an allowed d(An,Xn) or d(PC,Xn) mode also permits the corresponding 68020 indexed and memory indirect forms. See 68020 addressing. More
#imm
An immediate value. As the first operand, it selects a bit: 0 to 31 for a data register, or 0 to 7 for memory. More
* --- Z flag reflects the ORIGINAL bit value ---
move.l #%0101, d0
btst #0, d0 ; bit 0 = 1, Z flag clear
move.l #%0101, d1
btst #1, d1 ; bit 1 = 0, Z flag set

* --- Test higher bits ---
move.l #$80000000, d2
btst #31, d2 ; bit 31 = 1, Z flag clear