OPTIONAL Lab D2: C Callable Assembly
OPTIONAL Lab D2: C Callable Assembly
Objective
The objective of this lab is to practice and verify the mechanics of implementing a C callable
assembly programming. In this lab, a C file will be used to call the sum-of-products (from the
previous Appendix LabC exercise) by the “main” routine. Additionally, we will learn how to use
Code Composer Studio to configure the C build options and add the run-time support library to
the project. As in previous labs, you may perform the lab based on this information alone, or may
refer to the following procedure.
Procedure
Copy Files, Create Project File
1. Create a new project in C:\C28x\Labs\Appendix\LabD2 called LabD2.pjt and
add LabD2.c, LabD2.cmd, and sop-c.c to it. Also, add the compiler run-time
support library to the project (C:\ti\c2000\cgtools\lib\rts2800_ml.lib).
2. Do not
add LabC.asm to the project (copy of file from Appendix Lab C). It is only
placed here for easy access. Parts of this file will be used later during this lab exercise.
3. Setup the Build Options. Select the Linker tab and in the middle of the screen select
“Run-time Autoinitialization” under “Autoinit Model:”. Create a
map file by typing .\Debug\LabD2.map in the Map Filename [-m] field.
Do not enter anything in the “Code Entry Point (-e):” field (leave it blank).
Set the stack size to 0x400. Next, select the Compiler tab. Note that “Full
Symbolic Debug (-g)” under “Generate Debug Info:” in the Basic
Category is selected. On the Feedback Category pull down the interlisting options and
select “C and ASM (-ss)”. On the Assembly Category check the Keep
generated .asm Files (-k), Keep Labels as Symbols(-as) and
Generate Assembly Listing Files (-al). The –as will allow you to see
symbols in the memory window and the –al will generate an assembly listing file (.lst
file). The listing file has limited uses, but is sometime helpful to view opcode values and
instruction sizes. (The .lst file can be viewed with the editor). Both of these options will
help with debugging. Then select OK to save the Build Options.
Build and Load
4. Click the “Rebuild All” button and watch the tools run in the build window. Be
sure the “Load program after build” option is selected in Code Composer
Studio. The output file should automatically load. The Program Counter should be
pointing to _c_int00 in the Disassembly Window.
5. Under Debug on the menu bar click “Go Main”. This will run through the C
initialization routine in Boot.asm and stop at the main routine in LabD2.c.
C28x – C Programming D - 17