Chapter3 C
Chapter3 C
C / C++
Learning Objectives
Example :
lnk6x -c prog1 prog2 prog3 -o prog.out -l rts6200.lib
when you link while compiling, the linker options must follow the -z
option. The -z option divides the command line into compiler options
(options before -z) and linker options (options following -z).
Example :
cl6x -sq prog.c -z c.cmd -o prog.out -l rts6200.lib
options Options affect how the stand-alone simulator acts and how it
handles your .out file. Options can appear anywhere on the
command line.
filename.out Names the ‘.out’ file to be loaded into the stand-alone
simulator. The ‘.out’ file must be an executable COFF file.
Example (C code):
extern ”C” {
extern int asmfunc(int a); /* declare external as function */
int gvar = 4; /* define global variable */
}
void main( )
{
int i = 5;
i = asmfunc(i); } /* call function normally */
Example : C program
Example : C program
extern int table_size; /*external ref */
#define TABLE_SIZE ((int) (&table_size))
….
….
for (i=0; i<TABLE_SIZE; ++i)
….
….
/* use like normal symbol */
Data Types
Keywords
Pragma Directives
Initializing Static and Global Variables
Changing the ANSI C Language Mode
Data Type
main()
{
printf (”AMR = %x\n”, AMR); }
The -pk, -pr, and -ps options let you specify how the C/C++
compiler interprets your source code. You can compile your source
code in the following modes:
- Normal ANSI mode
- K&R C mode
- Relaxed ANSI mode
- Strict ANSI mode