Bit Set and Clear — BSC
The bit set and clear (BSC) addressing mode is used only by the BSET and BCLR instructions. Like other read-modify-write instructions, BSET and BCLR take a direct address. There are eight BSET and BCLR opcodes, one for each bit in a byte.
Consider the following line of code…
In this example, 0 £ n £ 7 and denotes one of the eight bits in a byte. This assembles to one of the BSET opcodes (calculated at $10 + 2n) and the direct address $00.
BCLR instructions are formed the same way…
As above, 0 £ n £ 7 and denotes one of the eight bits in a byte. This assembles to one of the BCLR opcodes (calculated at $11 + 2n) and the direct address $00.
Notes:
Bit set and bit clear instructions have a unique addressing mode that is similar to direct mode. The source code format for these instructions is:
BSET/BCLR bit_number, direct_address
Although each instruction has two operands, an assembled BSET or BCLR instruction consists only of an opcode and a direct address. Each bit that can be modified has its own BSET and BCLR opcodes.
The BSET opcodes for bits 0, 1, 2, 3, 4, 5, 6, and 7 are $10, $12, $14, $16, $18, $1A, $1C, and $1E, respectively. Similarly, the BCLR opcodes for bits 0, 1, 2, 3, 4, 5, 6, and 7 are $11, $13, $15, $17, $19, $1B, $1D, and $1F, respectively.
Like other read-modify-write instructions that take a direct address, BSET and BCLR execute in 5 clock cycles.