Texas Instruments TMS470R1x Barcode Reader User Manual


 
Getting Started With the C Compiler
5-7
Getting Started With the Code Generation Tools
5.2 Getting Started With the C Compiler
The TMS470R1x C compiler consists of many phases, including parsing, opti-
mization, and code generation. The simplest way to compile is to use the shell
program, which is included with the compiler. This section provides a quick
walkthrough so that you can get started without reading the entire
TMS470R1x
Optimizing C Compiler User’s Guide
.
1) Create a sample file called function.c that contains the following code:
/**************************************/
/* function.c */
/* (Sample file for walkthrough) */
/**************************************/
int main(int i)
{
return(i < 0 ? –i : i );
}
2) To invoke the shell program to compile and assemble function.c, enter:
cl470 –o function
By default, the TMS470R1x shell program compiles and assembles 32-bit
instructions. To compile 16-bit instructions, use the –mt option:
cl470 –o –mt funtion
The shell program prints the following information as it compiles the pro-
gram:
[function]
TMS470 ANSI C Compiler Version 1.20
Copyright (c) 1995–1997 Texas Instruments Incorporated
”function.c” ==> main
TMS470 ANSI C Optimizer Version 1.20
Copyright (c) 1995–1997 Texas Instruments Incorporated
”function.c” ==> main
TMS470 ANSI C Codegen Version 1.20
Copyright (c) 1995–1997 Texas Instruments Incorporated
”function.c”: ==> main
TMS470 COFF Assembler Version 1.20
Copyright (c) 1995–1997 Texas Instruments Incorporated
PASS 1
PASS 2
No Errors, No Warnings
By default, the shell deletes the assembly language file from the current
directory after the file is assembled. If you want to inspect the assembly
language output, use the –k option to retain the assembly language file:
cl470 –o –k function