Motorola SC140 user manual Save Ex7.c as Ex71.c

Page 22

Compiler Support on StarCore

Hands On

1.Open the example Ex7.c file.

2.Understand the conditional test in the code.

3.Compile the project with the -Ot2and -Soptions.

4.Open the generated assembly file Ex7.sl, and look at the conditional instructions within the loop.

5.In the box provided here, write down how many execution sets are within the loop:

Optimized for Time

Optimized for Space

6.Recompile using the compiler optimization option for code size (-Osoption).

7.Open the generated assembly file Ex7.sl, and look at the conditional instructions within the loop. Write down how many execution sets are within the loop in the box.

8.Save Ex7.c as Ex7_1.c.

9.Modify the program to obtain two cycles within the loop. Tip: consider using a temporary variable for both storing the immediate value of the array1 and the conditional test.

10.Compile the code using the -Ot2option.

11.Open the file Ex7_1.sl.

12.If you have obtained two cycles for the inner loop, congratulations. If you have not, please try again.

13.In the following box, write the optimized C code.

C Code

Generated Assembly Code

22

Introduction to the SC140 Tools

Image 22
Contents Motorola Typical development process is represented in Figure Compiler Hands On File I/O ExerciseGood 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