Motorola SC140 user manual First Code Section

Page 14

Compiler Support on StarCore

The following instructions require data to be aligned on the specified boundaries:

move.w

(r0),d0

2-byte boundary

move.f

(r0),d0

2-byte boundary

move.2w

(r0), d0:d1

4-byte boundary

move.2f

(r0), d0:d1

4-byte boundary

move.4w

(r0),d0:d1:d2:d3

8-byte boundary

move.4f

(r0),d0:d1:d2:d3

8-byte boundary

move.l

(r0),d0

8-byte boundary

move.2l

(r0),d0:d1

8-byte boundary

Hands On

1.Open the Ex4.c file, which contains a series of assembly instructions within a C framework using asm statements. For alternative (and nicer) ways of incorporating assembly code, consult the SC100 C/C++ Compiler User’s Manual.

2.Look at the assembly instructions to understand the wide data move instructions. Notice that the code comprises two sections: the first section with aligned data and the second with non-aligned data.

3.For each instruction, write the result you expect from each section in the boxes provided here (in the Expected Columns). Array “data[ ]” is of type long int and therefore aligns on a 4-byte boundary.

data:

0x01

0x231 0x45 0x67 0x89 0xAB

0xCD

0xEF

 

0xAA

0xBB 0xCC 0xDD 0xEE 0xFF

 

0x11

0x22

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

move #data,r0

 

 

 

 

 

 

 

 

 

 

Expected

 

 

 

 

 

 

Simulator

 

r0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

00

0000

 

0100

 

 

 

 

 

 

 

 

move.w (r0),d0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

d0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

move.2w (r0),d0:d1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

d0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

d1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

move.2f (r0),d2:d3

 

d2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

d3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

move.4w (r0),d4:d5:d6:d7

d4

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

d5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

d6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

d7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

move.2l (r0),d8:d9

 

d8

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

d9

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

First Code Section

14

Introduction to the SC140 Tools

Image 14
Contents Motorola Typical development process is represented in Figure Compiler Good To Know File I/O ExerciseHands On 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