Hardware Reference
In-Depth Information
bb dc.w
6
org
$1010
result ds.w
2
org
$1500
ldx
#aa
; set X to point to constant aa
ldy
#xx
; set Y to point to variable xx
movw
bb,result
1
2
; store b in the result
movw
#0,result
; “
emacs
result
; perform the multiplication and accumulation
swi
end
▲
Many applications (for example,
digital filtering
) involve the evaluation of polynomials.
The emacs instruction can be used to compute the value of a polynomial. Before utilizing
this instruction, we must transform the polynomial to a form that can take advantage of this
instruction. The polynomial
a
n
x
n
1
a
n
2
1
x
n
2
1
1
…
1
a
1
x
1
a
0
can be transformed into the format
(
x
(
x
(
…
(
a
n
x
1
a
n
2
1
)
1
a
n
2
2
)
1
…
a
1
)
1
a
0
)
The expression enclosed by each pair of parentheses in the polynomial requires the com-
putation of a multiplication followed by an addition and hence can be evaluated using the
emacs instruction. The actual computation is quite straightforward and is left as an exercise
problem.
An assembly language program consists of three major parts:
assembler directives
,
as-
sembly language instructions
, and
comments
. A statement of an assembly language program
consists of four fields:
label
,
operation code
,
operand
, and
comment
. Assembly directives sup-
ported by the freeware
as12
were all discussed in this chapter.
The HCS12 instructions were explained category by category. Simple program examples
were used to demonstrate the applications of different instructions. The HCS12 is a 16-bit mi-
crocontroller. Therefore, it can perform 16-bit arithmetic. Numbers greater than 16 bits must
be manipulated using multiprecision arithmetic.
Microcontrollers are designed to perform repetitive operations. Repetitive operations are
implemented by program loops. There are two types of program loops:
infinite loops
and
finite
loops.
There are four major variants of the looping constructs.
•
Do
statement
S
forever
•
For
i
5
n
1
to
n
2
do
S
or
For
i
5
n
2
downto
n
1
do
S
•
While
C
do
S
•
Repeat
S
until
C
In general, the implementation of program loops requires
•
The initialization of loop counter (or condition)
•
Performing the specified operation
Search WWH ::
Custom Search