DSPRelated.com
Forums

ADSP-21060 Compute and Move instruction

Started by Waldron, Donald M April 8, 2003
When using a compute and move instruction, is it safe to increment the same
register (in the compute portion)
and write the register to memory (in the move portion)?

Example:

r1 = 0x01;
r4 = 4096;
i4 = 0x800000;
lcntr = r4, do 1 until lce
r1 = r1 + 1, dm(i4, m6) = r1; /* <<<< IS THIS SAFE?? */

I expect r1 will get incremented AFTER it is written to where i4 points to,
then i4 gets incremented (m6=1),
so memory gets filled with an incrementing pattern.
IS THIS A SAFE ASSUMPTION? Regards, Donald M. Waldron
Principal Software Engineer
/////////// DETAILS BELOW //////////
Here's a code snippet of where I use this as part of a memory test: unsigned *dpram_mem_ptr;

static void fill_dpram(int num_locs);

main()
{
dpram_mem_ptr = 0x800000;
fill_dpram(4096);
}

/*
*********************************************************************
*
* fill_dpram
*
* test_value = INIT_PATTERN;
* for (i=0; i < num_locs; i++)
* {
* *dpram_mem_ptr++ = test_value++;
* }
*
***********************************************************************
*/
static void fill_dpram(int num_locs)
{
asm("r1 = 0x00000001;");
asm("r2 = dm(_dpram_mem_ptr);");

asm("i4 = r2;");
asm("lcntr = r4, do 1 until lce;");
asm("r1 = r1 + 1, dm(i4, m6) = r1;"); <<<<< IS THIS SAFE?
} /* fill_dpram */




On Tue, 8 Apr 2003, Waldron, Donald M wrote:

> When using a compute and move instruction, is it safe to increment the same
> register (in the compute portion)
> and write the register to memory (in the move portion)?
>
> Example:
>
> r1 = 0x01;
> r4 = 4096;
> i4 = 0x800000;
> lcntr = r4, do 1 until lce
> r1 = r1 + 1, dm(i4, m6) = r1; /* <<<< IS THIS SAFE?? */
>
> I expect r1 will get incremented AFTER it is written to where i4 points to,
> then i4 gets incremented (m6=1),
> so memory gets filled with an incrementing pattern.
> IS THIS A SAFE ASSUMPTION?
>

Yes, that's how it works. In the read portion, r1 is fed as is to both
the compute and transfer ops, then the compute and transfer are done
independently. It's perfectly legal and functional.

Patience, persistence, truth,
Dr. mike