401
APPENDIX B Instructions
B.6
Bit Manipulation Instructions (SETB, CLRB)
The bit manipulation instructions use a different read operation to the normal
operation for some bits of peripheral function registers.
s Read-modify-write Operation
Bit manipulation instructions set to "1" (SETB) or clear to "0" (CLRB) the specified bit only of a
register or RAM location. However, as the CPU handles data in 8-bit units, the actual operation
consists of reading the 8-bit data, modifying the specified bit, then writing the result back to the
same address. This is called a read-modify-write operation.
Table B.6-1 "Bus Operation for Bit Manipulation Instructions" shows the bus operation for bit
manipulation instructions.
s Read Source When Executing Bit Manipulation Instructions
The read source for a read-modify-write of some I/O ports and interrupt request flag bits is
different than for a standard read.
r I/O ports (Bit manipulation instructions)
For some I/O ports, a standard read reads the I/O pin values whereas a bit manipulation
instruction reads, the output latch value.
This is to prevent unintentionally modifying other
output latch bit values and is independent of the pin input/output direction or pin state.
r Interrupt request flag bits (Bit manipulation instructions)
For interrupt request flag bits, a standard read reads the flag bit to determine whether an
interrupt has occurred. Bit manipulation instructions, however, always read interrupt request
flag bits as "1". This is to prevent unintentionally clearing the flag by writing "0" to the interrupt
request flag bit when performing bit manipulation of a different bit.
Table B.6-1 Bus Operation for Bit Manipulation Instructions
Code
Mnemonic
~
Cycle
Address bus
Data bus
RD
WR
RMW
A0 to A7
A8 to AF
CLRB dir:b
SETB dir:b
41
2
3
4
N+1
dir address
N+2
dir
Data
Next instruction
0
1
0
1
0
1
0
1
0