Vous êtes sur la page 1sur 4

Expt.

No:3

SUM OF PRODUCTS using Assembly Language and C-Programming


OBJECTIVE:

To perform sum of products so that this principle can be easily and economically applied to convolution process.

ALGORITHM:

SUM OF PRODUCT

( )
a(n) = { 1,1,1,1,1,1,1,1,1,1} x(n) = { 1,1,1,1,1,1,1,1,1,1}
ASSEMBLY LANGUAGE PROGRAM:

( )

( )

.global _main z .half 1,1,1,1,1,1,1,1,1,1 x .half 1,1,1,1,1,1,1,1,1,1 y .half 0 _main: mvkl .S1 z,A5 mvkh .S1 z,A5 mvkl .S1 x,A6 mvkh .S1 x,A6 mvkl .S1 y,A7 mvkh .S1 y,A7 zero .S1 A4 mvk .S1 0Ah,A2 LOOP: ldh .D1 *A5++,A0 ldh .D1 *A6++,A1 nop 4 mpy .M1 A0,A1,A3 nop add .L1 A4,A3,A4 sub .S1 A2,1,A2 [A2] B .S1 LOOP nop 5 sth .D1 A4,*A7 nop

; Initialize A5 ; Initialize A6

; A2=10,LOOP COUNT ;A0= a(n) ;A1=x(n) ;A3=a(n)*x(n) ;Y=Y+A3 ;Decrement loop count ;If A2 != 0, BRANCH ; *A7=Y

PROCEDURE:

Open Code Composer Studio, Start a new project using Project-new pull down menu, save it in a separate directory(c:\ccstudio\myprojects) with name sop.pjt. Add the source files sop.asm to the project using Projectadd files to project pull down menu. Add the run time support library file rts6700.lib (Path: c:\ti\c6000\cgtools\lib\rts6700.lib) Compile the program using the Project-compile pull down menu or by clicking the shortcut icon on the left side of program window. Build the program using the Project-Build pull down menu or by clicking the shortcut icon on the left side of program window. Load the program(sop.out) in program memory of DSP chip using the File-load program pull down menu. To View output graphically Select view memory. Input: Z = a[n] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1} X = x[n] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1} Output: y = 0000000ah

EQUIVALENT C PROGRAM TO IMPLEMENT SUM OF PRODUCTS #include<stdio.h> int x[10]={1,1,1,1,1,1,1,1,1,1}; int y[10]={1,1,1,1,1,1,1,1,1,1}; int z; main() { int i; int sum; sum=0; for(i=9;i>=0;i--) { sum = sum + x[i]*y[i]; } z= sum; } Input: x[n] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1} y[n] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1} Output: Z=10

Output in Watch Window

Vous aimerez peut-être aussi