EE 5373/7373

DSP Programming Lab

 

Lab 2: TMS320C54x Addressing Modes and Arithmetic Instructions

 

Goals: The object of this lab is to familiarize you with several important addressing modes and with two basic arithmetic operations. The first is the arithmetic mean of a sequence of numbers while the second is a sum of products. The sum of products forms the basis for implementation of digital filters and is therefore one of the most important arithmetic computations for DSP's.

 

Preparation: You should be familiar with the TMS320C54x immediate, absolute, direct, and indirect addressing modes. You should also be familiar with COFF concepts and with arithmetic instructions for adding, multiplying, and multiply and accumulating. Before beginning the lab, read this lab assignment carefully and have a first draft of your programs written before you begin the lab.

 

1.      Write a program that places the numbers 1, 5, 7, 9, 10, -7, 8, -4, -1 in data memory starting at memory location 8000h = coeff. Put the numbers 2, 5, 12, -10, 8, 3, 4, 10, 15 in data memory starting at location 8009h = dat. Begin your program at program memory location 80h = start, set up a reset vector as in Lab 1. Then place the sum of products of these two sets of numbers in data memory location 8012h = sop.  Use the MPY (single operand) instruction. Use the following incomplete program as a guide:

 

; lab2b.asm

; this program finds sum of products

          .data     ;initialized data to follow

coeff:    .int 1, 5, 7, 9, 10, -7, 8, -4, -1  

 

dat:      .int 2, 5, 12, -10, 8, 3, 4, 10, 15   

sop: .int 0         ;space for SOP

       

          .def start     ;define start label for ext. ref.

          .text              ;defines start of program

start:    LD   *(coeff),T    ;first coeff (1) in T reg.

MPY  *(dat), A     ;mult T reg by 2 and put

                   ;result in A

          LD   *(coeff+1),T  ;next number in T

          MAC  *(dat+1), A   ;accumulate next product

          ...                ;add several lines here

          LD   #sop,DP       ;load DP

          STL  A, sop         ;store mean  

          NOP

done B    done     

 

Fill in the following table by opening up a memory window (Data Memory):       

 

8000h

8001h

8002h

8003h

8004h

8005h

8006h

8007h

8008h

8009h

 

 

 

 

 

 

 

 

 

 

 

800Ah

800Bh

800Ch

800Dh

800Eh

800Fh

8010h

8011h

8012h

 

 

 

 

 

 

 

 

 

 

2.      Repeat part 1, however this time use a loop involving  MAC (dual operand, use indirect addressing) and the RPTZ instructions. Verify that you get the correct sum of products.

 

  1. Read the Help file on “Profiling” in Code Composer Studio and determine the number of instruction cycles required to compute the program in parts 1, and 2. Count the number of cycles required starting with the first "STM" instruction to the NOP instruction. Number of cycles for #1 ______________, Number of cycles for #2 _______________. Submit a copy of your code for both parts and explain the difference in the number of cycles required to do the computation.