Compiler Support on StarCore

Exercise 5: /*****************************************************************************

*

MOTOROLA INC.

*

SEMICONDUCTOR PRODUCTS SECTOR

*

COPYRIGHT 1999 MOTOROLA INC.

*******************************************************************************

*

INTRODUCTION TO THE SC140 TOOLS

*

Developed by MOTOROLA SPS/NCSG/WISD

*******************************************************************************/

/* Split Summation Technique Exercise */

#include <stdio.h> #include <prototype.h>

short x[12] = {0,1,2,3,4,5,6,7,8,9,10,11};

main()

{

short i;

long res1=0, res2=0, res3=0, res4=0;

for(i=0;i<12;i+=4)

{

res1 = L_mac(res1, x[i], x[i]); res2 = L_mac(res2, x[i+1], x[i+1]); res3 = L_mac(res3, x[i+2], x[i+2]); res4 = L_mac(res4, x[i+3], x[i+3]);

}

/* To optimise the code further break the following dependency */ /* res1 = res1 + res2 + res3 + res4; */

/* into */

res1 = res1 + res2; res3 = res3 + res4;

res1 = res1 + res3;

printf("Result = %d (0x%x)\n", res1,res1);

}

30

Introduction to the SC140 Tools

Page 30
Image 30
Motorola SC140 user manual Motorola INC