Motorola SC140 user manual Current

Page 24
Low Address

Compiler Support on StarCore

High Address

SP

(Current)

SP

SP

SP

Return

Address

Parameters

3, 4, 5, ...

Local

Variables

(if any)

Saved

Registers

Return

Address

Parameters

3, 4, 5, ...

SP

 

Return

 

Address

SP

Parameters

 

3, 4, 5, ...

 

Parameters

3, 4, 5, ...

SP

¹

²

³

¼

½

¹ Prior to function call

²On entry to function

³During function execution ¼ Prior to exit from function ½ On return from function

ª Calling function deallocates parameters on stack

ª

Figure 11. Typical Stack Contents During Function Execution

Therefore, for the function addvecs(), parameters x[], and y[] are passed in r0 and r1, while z[] and M are passed on the stack.

Hands On

1.Open the Ex8.c and addvecs.asm files, and familiarize yourself with the code.

2.In addvecs.asm are two constants, Z_OFFSET and M_OFFSET, whose values are not set and which are represented by question marks (???). These offsets pull z[] and M from the stack. Find the lines of code that perform this task.

3.Before the code can be built, you must assign values to Z_OFFSET and M_OFFSET. To help you to do this, Figure 12 shows the stack on entry to addvecs().

24

Introduction to the SC140 Tools

Image 24
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