btr - bit test and reset

CF = bit(dest, source)  ; extract & reset bit numbered by source from dest
bit(dest,source) = 0

The btr instruction uses the source value as the bit number of the destination to test and reset. The destination can be a 64, 32 or 16 bit register or memory location. The source can be either an immediate value or a register of the same size as the destination.

When testing and resetting based on a memory address using a register as source operand, the register can hold a larger integer which defines a doubleword in memory to test and a bit within the doubleword. So you can access an array of bits.

Probably the most likely use of btr is simply to reset a particular bit. It just happens that testing can be done in the same instruction and you can ignore the CF.

Some examples of using btr:

        btr     rax, 15         ; test and reset bit 15 of rax
        btr     eax, 10         ; test and reset bit 10 of eax
        btr     dx, cx          ; cx contains bit number of dx to test & reset
        btr     [x], rdx        ; rdx contains bit number of x to test & reset

flags: CF