AnsweredAssumed Answered

ASM/C Loop Performance Comparison

Question asked by dougcl on Dec 30, 2013
Latest reply on Jan 2, 2014 by MaheshN

Hi folks, this evening I tried a test on the 21489 EZKIT. I created a new project in CCES, looping 4096 times and valuing an integer array in memory. In the ASM case, the loop takes about 20us in seg_dmda, and about 75us in seg_sdram.

In C, using seg_dmda, it took 175us. In C, using seg_sdram, it took 200us. Are these numbers to be expected?



Here is the ASM loop (variable junk declared like this: .var junk[4096];)



   r0 = 0;

   i1 = junk;

   m1 = 1;

   lcntr = 4096, do looptag until lce;

   dm(i1,m1) = r0;

looptag: r0 = r0 + 1;





Here is the C loop (junk declared like this: int junk[4096];)

for (int i=0;i<4096;i++){

  junk[i] = i;