# Bit Manipulation

These instructions affect single bits in a byte. All instructions test the bit before affecting it.

BTST | Tests a bit
BSET | Tests a bit, then sets it (1)
BCLR | Tests a bit, then resets it (0)
BCHG | Tests a bit, then inverts it (0 -> 1, 1 -> 0)

Bit field instructions allow manipulation of bits across a 32 bit field. Bit field instructions were introduced in the 68020 microprocessor and are not supported by the 68000 microprocessor. EASy68K is normally a 68000 only environment but does support a modified form of bit field instructions for educational purposes. In EASy68K the bit field instructions are restricted to using only 68000 addressing modes. An assembler directive or menu option in EASy68K enables or disables the assembly of bit field instructions.

BFCHG | Test a bit field, then complement it
BFCLR | Test a bit field, then clear it to 0
BFEXTS | Test a bit field, then sign extend it to 32 bits and load it into the specified data register
BFEXTU | Test a bit field, then zero extend it to 32 bits and load it into the specified data register
BFFFO | Test a bit field, then put the bit number of the first bit that contains 1 in the specified data reigster
BFINS | Insert the bit field from the specified data register into the destination, then set the condition codes
BFSET | Test a bit field, then set it to 1
BFTST | Test a bit field