bchg

Test a bit and change

Inverts the bit in the second operand numbered by the first operand, setting Z to the inverse of its old value.

Sizes .b .l

Used in
XNZVC ––●––
  • ● set from 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
* --- Toggles the specified bit ---
move.l #%0001, d0
bchg #0, d0 ; bit 0 was 1, now 0. Z flag clear (old value)
bchg #0, d0 ; bit 0 was 0, now 1. Z flag set (old value)

move.l #%0000, d1
bchg #3, d1 ; bit 3 was 0, now 1. Z flag set