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 instruction’s supported addressing modes, such as d0, (a0)+ or 4(a1). It may name a register, memory or an immediate value. 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