AnsweredAssumed Answered

Nested Loops on ADSP-218x

Question asked by goldscott on Dec 2, 2011
Latest reply on Dec 20, 2011 by goldscott

Hello All,

 

I'm using VDSP 3.5 and ADSP-2188, programming in assembly.

 

I'm trying to write a nested loop where both loops end at the same location. The processor (I'm using the simulator) doesn't seem to like it when the loops end at the same location.

 

My code is posted below:

 

    mx0 = dm(i0,m0);            //get first data value.
    cntr = CBS_INPUT_SAMPLES;   //loop for each sample.
    do sampleLoop until ce;
        my0 = pm(i6,m6);            //get cosine value & increment ptr.
        my1 = pm(i7,m6);            //get sine value & increment ptr.
        cntr = dm(CbsNumBeams);     //loop for all channels (beams).
        do channelLoop until ce;
            mr = mx0 * my0 (rnd);       //data*cosine.
            dm(i1,m0) = mr1;            //store cos result in output buffer & inc output ptr.
            mr = mx0 * my1 (rnd), mx0 = dm(i0,m0);  //data*sine, get next data value.
        channelLoop:
    sampleLoop:
            dm(i1,m0) = mr1;            //store sin result in output buffer & inc output ptr.
        //end channelLoop.
    //end sampleLoop.

    rts;

 

As you can see, both sampleLoop and channelLoop end at the same address.

What appears to be happening is that after executing all cycles of the inner loop, the counter for the outer loop never gets decremented.

 

Is there any way to solve this other than to either put another one or more instructions after channelLoop? (My current fix is to put the my0 and my1 loads after the channelLoop) and also initially load them after the mx0 load, as shown below:

 

    mx0 = dm(i0,m0);            //get first data value.
    my0 = pm(i6,m6);            //get first cosine value & increment ptr.
    my1 = pm(i7,m6);            //get first sine value & increment ptr.
    cntr = CBS_INPUT_SAMPLES;   //loop for each sample.
    do sampleLoop until ce;
        cntr = dm(CbsNumBeams);     //loop for all channels (beams).
        do channelLoop until ce;
            mr = mx0 * my0 (rnd);       //data*cosine.
            dm(i1,m0) = mr1;            //store cos result in output buffer & inc output ptr.
            mr = mx0 * my1 (rnd), mx0 = dm(i0,m0);  //data*sine, get next data value.
        channelLoop:
            dm(i1,m0) = mr1;            //store sin result in output buffer & inc output ptr.
        //end channelLoop.
        my0 = pm(i6,m6);            //get cosine value & increment ptr.
    sampleLoop:
        my1 = pm(i7,m6);            //get sine value & increment ptr.
    //end sampleLoop.

 

I don't like this because I feel it's wasting two program memory locations.

 

Edit: And doing it this way, I must also modify i6 and i7 by -m6 in order to get them to point back to the correct address, so I am actually wasting more PM and cycles.

 

Thanks,
Scott

Outcomes