Hardware Reference
In-Depth Information
or a few bits. The exclusive or instruction can be used to toggle (change from 0 to 1 and from 1
to 0) one or a few bits. For example, the instruction sequence
ldaa $56
anda #$0F
staa $56
clears the upper four pins of the I/O port located at $56. The instruction sequence
ldaa $56
oraa #$01
staa $56
sets the bit 0 of the I/O port at $56. The instruction sequence
ldaa $56
eora #$0F
staa $56
toggles the lower 4 bits of the I/O port at $56. The instructions ( coma and comb ) that perform
one's complementing can be used if all of the port pins need to be toggled.
2.9 Bit Test and Manipulate Instruction
These instructions use a mask value to test or change the value of individual bits in an ac-
cumulator or in a memory location. The instructions bita and bitb provide a convenient means
of testing bits without altering the value of either operand. Table 2.8 shows a summary of bit
test and manipulation instructions.
Mnemonic
Function
Operation
bclr <opr> 2 , msk8
bita <opr> 1
bitb <opr> 1
bset <opr> 2 , msk8 2
Clear bits in memory
Bit test A
Bit test B
Set bits in memory
M (M) • (mm)
(A) • (M)
(B) • (M)
M
(M) + (mm)
Note:
1. <opr> can be specified using all except relative addressing modes
for bita and bitb.
2. <opr> can be specified using direct, extended, and indexed
(exclude indirect) addressing modes.
3. msk8 is an 8-bit value.
Table 2.8 Summary of bit test and manipulation instructions
For example, the instruction
bclr 0,x,$81
clears the most signifi cant and the least signifi cant bits of the memory location pointed to by
index register X. The instruction
bita
#$44
 
Search WWH ::




Custom Search