Hardware Reference
In-Depth Information
Example 2.24
Write a program to shift the 32-bit number stored at $1000,$1003 to the right four places.
Solution: The most significant to the least significant bytes are stored at $1000,$1003. The fol-
lowing instruction sequence implements the algorithm that we just described:
ldab
#4
; set up the loop count
ldx
#$1000
again
lsr
0,x
ror
1,x
ror
2,x
ror
3,x
dbne
b,again
2.8 Boolean Logic Instructions
When dealing with input and output port pins, we often need to change the values of a few
bits. For these types of applications, the Boolean logic instructions come in handy. A summary
of the HCS12 Boolean logic instructions is given in Table 2.7.
The operand opr can be specified using all except the relative addressing modes. Usually,
we would use the and instruction to clear one or a few bits and use the or instruction to set one
Mnemonic
Function
Operation
anda <opr>
andb <opr>
andcc <opr>
eora <opr>
eorb <opr>
oraa <opr>
orab <opr>
orcc <opr>
clc
cli
clv
com <opr>
coma
comb
neg <opr>
nega
negb
AND A with memory
AND B with memory
AND CCR with memory (clear CCR bits)
Exclusive OR A with memory
Exclusive OR B with memory
OR A with memory
OR B with memory
OR CCR with memory
Clear C bit in CCR
Clear I bit in CCR
Clear V bit in CCR
One's complement memory
One's complement A
One's complement B
Two's complement memory
Two's complement A
Two's complement B
A (A) • (M)
B (B) • (M)
CCR (CCR) • (M)
A (A) (M)
B (B) (M)
A (A) + (M)
B (B) + (M)
CCR (CCR) + (M)
C 0
I 0
V 0
M $FF − (M)
A $FF − (A)
B $FF − (B)
M $00 − (M)
A $00 − (A)
B $00 − (B)
Table 2.7 Summary of Boolean logic instructions
 
Search WWH ::




Custom Search