Hardware Reference
In-Depth Information
psha
pula
psha
pula
psha
pula
nop
nop
dbne
x,inner_loop
dbne
b,out_loop
; 3 E cycles
The time delay created by using program loops is not accurate. Some overhead is required to set
up the loop count. For example, the one-layer loop has a 2-E-cycle overhead while the two-layer
loop has much more overhead.
overhead 5 1 E cycle (caused by the ldab #100 instruction)
1 100 3 2 E cycles (caused by the out_loop ldx #60000 instruction)
1 100 3 3 E cycles (caused by the dbne b, out_loop instruction)
5 501 E cycles 5 20.875 μ s (at 24-MHz E-clock)
To reduce the overhead, one can adjust the number to be placed in index register X. For ex-
ample, by placing 59999 in X, one can create a delay of 9.99985 sec with the previous program,
which is closer to 10 sec.
2.11 The Multiply-and-Accumulate (emacs) Instruction
The multiply-and-accumulate ( emacs ) instruction multiplies two 16-bit operands stored in
memory and adds the 32-bit result to a third memory location (32 bit). EMACS can be used to
implement simple digital filters, defuzzification routines, and any operation that involves the
evaluation of linear polynomial functions.
When the emacs instruction is executed, the first source operand is fetched from a location
pointed to by index register X, and the second source operand is fetched from a location pointed
to by register Y. Before the instruction is executed, the X and Y index registers must contain
values that point to the most significant bytes of the source operands. The most significant byte
of the 32-bit result is specified by an extended address supplied with the instruction.
Example 2.27
Write an assembly program to compute the following expression using the emacs instruction:
a 3 y 1 b
where a , y , and b are in memory locations $1000, $1002, and $1004, respectively. Leave the re-
sult in memory location $1010,1013.
Solution: The value of b should be stored in memory locations $1012,$1013, and index registers
X and Y should be set up to point to memory locations $1000 and $1002. We also need to store
the constant in the destination. The following program performs the desired computation:
org
$1000
aa dc.w
10
xx dc.w
7
 
Search WWH ::




Custom Search