Hardware Reference
In-Depth Information
Add Instructions
Mnemonic
Function
Operation
ABA
Add B to A
A [A] + [B]
X
[X] + [B]
ABX
Add B to X
Y [Y] + [B]
ABY
Add B to Y
ADCA <opr>
Add with carry to A
A
[A] + [opr] + C
B [B] + [opr] + C
ADCB <opr>
Add with carry to B
ADDA <opr>
Add without carry to A
A
[A] + [opr]
B
[B] + [opr]
ADDB <opr>
Add without carry to B
ADDD <opr>
Add without carry to D
D
[D] + [opr]
Subtract Instructions
Mnemonic
Function
Operation
SBA
Subtract B from A
A [A] - [B]
A
[A] - [opr] - C
SBCA <opr>
Subtract with borrow from A
B [B] - [opr] - C
SBCB
Subtract with borrow from B
SUBA <opr>
Subtract memory from A
A
[A] - [opr]
B
[B] - [opr]
SUBB <opr>
Subtract memory from B
SUBD <opr>
Subtract memory from D
D [D] - [opr]
Table 1.8 Add and subtract instructions
1.11.4 Add and Subtract Instructions
Add and subtract instructions allow the HCS12 to perform fundamental arithmetic opera-
tions. A summary of add and subtract instructions is in Table 1.8. The <opr> field in Table 1.8
is specified using one of the legal addressing modes. All except inherent and relative modes are
legal addressing modes for these two groups of instructions.
Example 1.1
Write an instruction sequence to add 3 to the memory locations at $10 and $15.
Solution: A memory location cannot be the destination of an ADD instruction. Therefore, we
need to copy the memory content into an accumulator, add 3 to it, and then store the sum back
to the same memory location.
ldaa
$10
; copy the contents of memory location at $10 to A
adda
#3
; add 3 to A
staa
$10
; store the sum back to memory location at $10
ldaa
$15
; copy the contents of memory location at $15 to A
adda
#3
; add 3 to A
staa
$15
; store the sum back to memory location at $15
 
Search WWH ::




Custom Search