Aerospace



Discussion Forum

Home

Company Information

Information Request

Linux How-to Guides

ADSP 21xx
Digital Signal Processing
Tutorials

SW Utilities

On-line Order Form

Aerospace Projects

Commercial Projects

Circuit Boards

Server Support


bonk

Have you found this site useful? Did we save you time? Did we cure your head-ache? Is your hair growing back now?

Please make a donation to help with maintenance.


Objective Real-Time Software on the ADSP21XX

Objective Code

Introduction

Crucial to the manipulation of software objects is the efficient building of data pointers. The RISC like architecture of the ADSP family of digital signal processors with their large files of data index registers, is very well suited to this task, while the algebraic assembly language command set makes it easy to understand the flow of the code. The definition and use of multi dimensional data structures is best explained in a simple example.

An Audio Object

Let us examine the case of a 4 channel audio recorder. This device uses 4 CODECs for which we need a set of variables for the manipulation of Pulse Code Molulation (PCM) data. Our good friend Mr H.Acker would define the output audio variables as aud_a till aud_d. He would then handle the audio from the main program loop with calls to four procedures called aud_pcm_out_a till aud_pcm_out_d, like this:

Example 1. Traditional Assembler Code

.VAR/DM/RAM/SEG=INT_DM  aud_a,
                        aud_b,
                        aud_c,
                        aud_d;
call aud_pcm_out_a;
call_aud_pcm_out_b;
call aud_pcm_out_c;
call aud_pcm_out_d;

This is however, clearly inefficient and is a typical example of redundant spaghetti code. H.Acker created four procedures that are essentially the same, except for the addresses of the variables they are accessing.

A better aproach would be to define a structure, with a for loop and indirect addressing, as in this flat C example, but how does one do this in assembler?

Example 2. A Flat C object.

typedef struct
{
   char aud_out;
}AUD_OBJECT_TYP;

AUD_OBJECT_TYP aud_object[4];

for(channel = 0; channel < 4; channel++)
   aud_pcm_out(&aud_object[channel]);

A Simple Assembler Object

Data structures are the essence of object oriented design. If we can effectively handle structured data in assembler, then we can write objective code. Objects are accessed with data pointers, using the index registers for indirect addressing.

Objective Code

Objects are accessed with data pointers, using the index registers for indirect adressing.

If an object consists of only 4 similar variables, a simple array declaration can be used.

Example 3. A simple assembler object.

/*
 * It is easy to declare an array
 */
#define    AUD_OBJECT0     0
#define    AUD_OBJECT1     1
#define    AUD_OBJECT2     2
#define    AUD_OBJECT3     3
#define    AUD_OBJECT_SIZE 4

VAR/DM/RAM/SEG=INT_DM aud_object[AUD_OBJECT_SIZE];

/*
 * but it is somewhat more work to access the array.
 * The DAG index registers provide a way to index into tables
 */
i0 = ^aud_object;
m0 = AUD_CHANNEL1;
l0 = 0;

modify(i0, m0);         /* Create a Pointer to the variable */
ax0 = dm(i0, m0);       /* Go get it */


Copyright © 1996-2008, Aerospace Software Ltd., GPL.