OPTIONAL Lab D2: C Callable Assembly
Verify C Sum of Products Routine
6. Debug using both source and assembly (by right clicking on the window and select
Mixed Mode
or using
View
→
Mixed Source/ASM
).
7. Open a memory window to view result and data.
8. Single-step through the C code to verify that the C sum-of-products routine produces the
results as your assembly version.
Viewing Interlisted Files and Creating Assembly File
9. Using
File
→
Open
view the
LabD2.asm
and
sop-c.asm
generated files. The
compiler adds many items to the generated assembly file, most are not needed in the C-
callable assembly file. Some of the unneeded items are .func / .endfunc. .sym, and .line.
10. Look for the _sop function that is generated by the compiler. This code is the basis for
the C-callable assembly routine that is developed in this lab. Notice the comments
generated by the compiler on which registers are used for passing parameters. Also,
notice the C code is kept as comments in the interlisted file.
11. Create a new file (
File
→
New
, or clicking on the left most button on the horizontal
toolbar “New”) and save it as an assembly source file with the name
sop-asm.asm
.
Next copy
ONLY
the sum of products function from
LabC.asm
into this file. Add a
_sop label to the function and make it visible to the linker (
.def
). Also, be sure to add a
.sect directive to place this code in the “code” section. Finally, add the following
instruction to the end:
LRETR ; return statement
12. Next, we need to add code to initialize the sum-of-products parameters properly, based
on the passed parameters. Add the following code to the first few lines after entering the
_sop routine: (Note that the two pointers are passed in AR4 and AR5, but one needs to
be placed in AR7. The loop counter is the third argument, and it is passed in the
accumulator.)
MOVL XAR7,XAR5 ;XAR7 points to coeff [0]
MOV AR5,AL ;move n from ACC to AR5 (loop counter)
SUBB XAR5,#1 ;subtract 1 to make loop counter = n-1
Before beginning the MAC loop, add statements to set the sign extension mode, set the
SPM to zero, and a ZAPA instruction. Use the same MAC statement as in Lab 4, but use
XAR4 in place of XAR2. Make the repeat statement use the passed value of n-1 (i.e.
AR5).
RPT AR5 ;repeat next instruction AR5 times
D- 18
C28x – C Programming
Содержание C28 Series
Страница 64: ...Summary 3 16 C28x Peripheral Registers Header Files ...
Страница 78: ...Interrupt Sources 4 14 C28x Reset and Interrupts ...
Страница 218: ...Lab 9 DSP BIOS 9 22 C28x Using DSP BIOS ...
Страница 244: ...Lab 10 Programming the Flash 10 26 C28x System Design ...
Страница 273: ...Appendix A eZdsp F2812 C28x Appendix A eZdsp F2812 A 1 ...
Страница 275: ...Appendix eZdsp F2812 eZdsp F2812 Connector Header and Pin Diagram C28x Appendix A eZdsp F2812 A 3 ...
Страница 276: ...Appendix P2 Expansion Interface A 4 C28x Appendix A eZdsp F2812 ...
Страница 277: ...Appendix P4 P8 P7 I O Interface C28x Appendix A eZdsp F2812 A 5 ...
Страница 278: ...Appendix A 6 C28x Appendix A eZdsp F2812 ...
Страница 279: ...Appendix P5 P9 Analog Interface C28x Appendix A eZdsp F2812 A 7 ...
Страница 281: ...Appendix JP7 JP8 JP11 JP12 Boot Mode Select JP9 PLL Disable DS1 DS2 LEDs C28x Appendix A eZdsp F2812 A 9 ...
Страница 282: ...Appendix A 10 C28x Appendix A eZdsp F2812 TP1 TP2 Test Points ...