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

Page 22
Image 22
Motorola SC140 user manual Save Ex7.c as Ex71.c