Digital Signal Processing Reference
In-Depth Information
..., code4 as 1, 2, 2, 4, respectively. The initial values of digit1 ,..., digit4 set as 1,
1, 1, 1, respectively, are passed to the asm function to compare these four digit values
with the four code values. Four sliders are used to change the digit values passed to
the asm function. The C source program, the asm function, and the gel file for the
sliders are included in the folder code_casm .
Build this project example as code_casm . Load and run the executable file. Press
switch #0 (SW0) slightly and verify that “no match” is continuously being printed
(as long as SW0 is pressed). Load the gel file code_casm.gel and set the sliders
Digit1 ,..., Digit4 to positions 1, 2, 2, 4, respectively. Slightly press SW0 and verify
that “correct match” is being printed (with SW0 pressed). Change the slider Digit2
from position 2 to position 3, and again press SW0 to verify that there is no longer
a match. The program is in a continuous loop as long as switch #3 (SW3) is not
pressed. Note that the initial value for the code (code1, ...,code4) can be readily
changed.
Example 3.6: Dot Product Using Assembly Program Calling an
Assembly Function ( dotp4a )
This example takes the sum of products of two arrays, each array with four numbers.
See also Example 1.3, which implements it using only C code, and Examples 3.2
through 3.5, which introduced the syntax of assembly code. Figure 3.17 shows a
; Dotp4a_init.asm ASM program to init variables.Calls dotp4afunc
.def
init ;starting address
.ref
dotp4afunc ;called ASM function
.text
;section for code
x_addr .short
1,2,3,4 ;numbers in x array
y_addr .short
0,2,4,6 ;numbers in y array
result_addr .short
0
;initialize sum of products
init MVK result_addr,A4 ;result addr -->A4
MVK 0,A3 ;A3=0
STH A3,*A4 ;init result to 0
MVK x_addr,A4 ;A4 = address of x
MVK y_addr,B4 ;B4 = address of y
MVK 4,A6 ;A6 = size of array
B dotp4afunc ;B to function dotp4afunc
MVK ret_addr,b3 ;B3=return addr from dotp4a
NOP 3 ;3 more delay slots(branch)
ret_addr MVK result_addr,A0 ;A0 = result address
STW A4,*A0 ;store result
wait B wait ;wait here
NOP 5 ;delay slots for branch
FIGURE 3.17. ASM program calling an ASM function to find the sum of products
( dotp4a_init.asm ).
Search WWH ::




Custom Search