Motorola SC140 user manual Motorola INC

Page 30

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

Image 30
Contents Motorola Typical development process is represented in Figure Compiler File I/O Exercise Hands OnGood To Know Integer and Fractional Arithmetic Exercise Interpretation of 16-bit Integer and Fractional Data ValuesCompiler Support on StarCore Integer ArithmeticFractional Arithmetic Good To Know Local Versus Global Optimization Exercise Local OptimizationCompiler Support on StarCore StarCore C Compiler Local Optimization Global OptimizationMemory Alignment Exercise AA BB CC DD First Code Section Second Code Section Split Summation Exercise Code Generated Assembly Code Multi-Sample Exercise = ∑ a i x n For 0 ≤ n LIntermediate Version Compromise Between Memory and Speed Further Speed Optimization Control Code The True Bit Exercise Save Ex7.c as Ex71.c Calling an Assembly Routine From C Exercise Current Following output should be displayed Challenge Solutions to Exercises Introduction to the SC140 ToolsExercise AlignedExpected Motorola INC Intermediate version Compromise between Memory and Speed Compiler Support on StarCore Further Optimizing the Speed Compiler Support on StarCore Compiler Support on StarCore Motorola INC Zoffset equ Moffset equ Exercise Compiler Support on StarCore Compiler Support on StarCore AN2009/D