background image

Содержание TMS34010

Страница 1: ... TEXAS INSTRUMENTS TMS34010 C Compiler 1988 Graphics Products ...

Страница 2: ...TMS34010 C Compiler Reference Guide TEXAS INSTRUMENTS ...

Страница 3: ...iques are utilized to the extent TI deems necessary to support this warranty Unless mandated by government requirements specific testing of all parameters of each device is not necessarily performed TI assumes no liability for TI applications assistance customer product design software performance or infringement of patents or services described herein Nor does TI warrant or represent that license...

Страница 4: ... for Include Files Parser gspcc Description Invoking the Parser General Information Code Generator gspcg Description Invoking the Code Generator Pointers to Named Variables a Option Small Code Model s Option Checking for Stack Overflow x option Compiling and Assembling a Program Linking a C Program Runtime Initialization and Runtime Support Sample Linker Command File Autoinitialization ROM and RAM...

Страница 5: ...errupt Handling Integer Expression Analysis Floating Point Support Floating Point Formats Double Precision Functions Single Precision Functions Conversion Functions Floating Point Errors System Initialization Initializing the Stack Autoinitialization of Variables and Constants 6 Runtime Support Functions 6 1 Header Files 6 1 1 Diagnostic Messages assert h 6 1 2 Character Typing and Conversion ctyp...

Страница 6: ...ample of a Linker Command File 3 14 5 1 The Program and System Stacks 5 3 5 2 An Example of a Function Call 5 8 5 3 Single Precision Format 5 18 5 4 Double Precision Format 5 18 5 5 Format of Initialization Records in the cinit Section 5 24 5 6 ROM Model of Autoinitialization 5 25 5 7 RAM Model of Autoinitialization 5 26 Table 6 1 6 2 Tables Macros that Supply Integer Type Range Limits Iimits h Ma...

Страница 7: ...4 TMS34010 C Language Discusses the differences between the C language supported by the TMS34010 C compiler and standard Kernighan and Ritchie C Section 5 Runtime Environment Contains technical information on how the compiler uses the TMS3401 0 ar chitecture discusses memory and register conventions stack organization function call conventions and system initialization provides information needed ...

Страница 8: ...resent the details and characteristics of this particular C compiler it as sumes that you already know how to write C programs We suggest that you obtain a copy of The C Programming Language by Brian W Kernighan and Dennis M Ritchie published by Prentice Hall use this reference guide as a supplement to the Kernighan and Ritchie book The TMS3401 0 C compiler can be installed on the following system...

Страница 9: ...ment Tools Overview 1 2 Object Libraries Figure 1 1 illustrates the TMS3401 0 software development flow The center portion of the figure highlights the most common path of software develop ment the other portions are optional Figure 1 1 TMS34010 Software Development Flow ...

Страница 10: ...imensional transformations and graphics initialization The font library contains a variety of proportionally spaced and monospaced fonts You can use the functions in the graphics li brary to display the fonts The CCITT data compression function library contains CCITT compatible routines for compressing and decompressing monochrome image data The 8514 adaptor emulation function library contains rou...

Страница 11: ... The TMS34010 CCITT Data Compression Function Library Us er s Guide literature number SPVU009 describes a collection of CCITT compatible routines for compressing and decompressing mono chrome image data The TMS34010 Font Library User s Guide literature number SPVU007 describes a set of fonts that are available for use in a TMS34010 based graphics system The TMS34010 User s Guide literature number ...

Страница 12: ...piler Version 3 xx c Copyright 1988 Texas Instruments Incorporated program c main In syntax descriptions the instruction command or directive is in a bold face font Parameters are in italics Here is an example of directive syntax line integer constant filename line is a preprocessor directive This directive has two parameters in dicated by integer constant and filename When you use Iine the first ...

Страница 13: ...oke the gspc bat batch file to compile and assemble function c enter gspc function The gspc command invokes the batch file which in turn invokes the C preprocessor C parser C code generator and the assembler In this example function c is the input source file Do not specify an ex tension for the input file the batch file assumes that the input file has an extension of c After you invoke the batch ...

Страница 14: ...ler the assembler creates an object file called function obj 3 The final output of the batch file is an object file This example creates an object file called function obj To create an executable object module link the object file created by the batch file with the runtime support library rts 1ib gsp1nk c function 0 function out 1 rts 1ib This examples uses the c linker option because the code cam...

Страница 15: ...Introduction 1 8 ...

Страница 16: ...the installation instructions for these systems in the following sections Section Page 2 1 PC Installations 2 2 2 2 VAX VMS Installation 2 3 2 3 UNIX Systems Installation 2 4 2 4 Macintosh MPW Installation 2 5 Note In order to use the TMS34010 C compiler you must also have the TMS34010 assembler and linker PC DOS is a trademark of International Business Machines 2 MS DOS is a trademark of Microsof...

Страница 17: ...r dual drive sys tems B Destination or system disk for dual drive systems C Winchester hard disk for hard disk systems E on TI PCs Follow these instructions to install the software 1 Make backups of the product diskettes 2 Create a directory to contain the C compiler If you re using a dual drive system put the disk that will contain the tools into drive B On hard disk systems enter MD C GSPTOOLS O...

Страница 18: ...e in this example DEST directory represents that directory Replace TAPE with the name of the tape drive you are using 3 allocate TAPE mount for den 1600 TAPE backup TAPE gspc bck DEST directory dismount TAPE dea110c TAPE The product tape contains a file called setup com This file sets up VMS symbols that allow you to execute the tools in the same manner as other VMS commands Enter the following co...

Страница 19: ...ry that you ll store the tools in is the current directory 3 Enter the tar command for your system for example tar x This copies the entire tape into the directory Note to Apollo Users These tools can run under either the AEGIS system or Domain IX How ever when you install the tools you must use Domain IX because the tape is in tar format and only Domain IX has a tar command If you are not ac cust...

Страница 20: ...ncludes directory contains the header files h files for the run time support functions Many of these files have names that conflict with commonly used MPW header files so you should keep these header files separate from the MPW files Copy the contents of the In clude directory into a new folder and use the C DIR environment vari able see Section 3 1 3 on page 3 4 to create a path to this folder 3 ...

Страница 21: ...Compiler Installation 2 6 ...

Страница 22: ...he preprocessor The parser produces an intermediate file Step 3 The input for the code generator is the intermediate file produced by the parser The code generator produces an assembly language source file After you compile a program you must assemble and link it with the TMS34010 assembler and linker Topics in this section include Section Page 3 1 Preprocessor gspcpp Description 3 2 3 2 Parser gs...

Страница 23: ...kes the preprocessor input file names a C source file that the preprocessor uses as input If you don t supply an extension the preprocessor assumes that the extension is c If you don t specify an input file the pre processor will prompt you for one output file names the modified source file that the preprocessor creates If you don t supply a filename for the output file the preprocessor uses the i...

Страница 24: ...ectives that are de scribed in Kernighan and Ritchie Appendix B summarizes these direc tives All preprocessor directives begin with the character which must appear in column 1 of the source statement Any number of blanks and tabs may appear between the sign and the directive name The C preprocessor maintains and recognizes five predefined macro names __ LINE _ _ represents the current line number ...

Страница 25: ... provide path information and you enclose the filename in double quotes the preprocessor searches for the file in 1 The directory that contains the current source file The current source file refers to the file that is being processed when the pre processor encounters the include directive 2 Any directories named with the i preprocessor option 3 Any directories set with the environment variable C ...

Страница 26: ...ort C DIR The pathnames are directories that contain include files You can separate pathnames with a semicolon or with blanks In C source you can use the include directive without specifying any path information instead you can specify the path information with C D IR For example assume that a file called source c contains these statements include altl c include alt2 c The table below lists the co...

Страница 27: ...tor Note that the input file can also be a C source file that has not been preprocessed Figure 3 3 illustrates this process Figure 3 3 Input and Output Files for the C Parser 3 2 1 Invoking the Parser 3 6 To invoke the parser enter gspcc input file output file options gspcc is the command that invokes the parser input file names the modified C source file that the parser uses as input If you don t...

Страница 28: ... corrected before you can finish compiling a program Some errors however merely produce warnings which hint of problems but do not prevent the parser from producing an intermedi ate file As the parser encounters function definitions it prints a progress mes sage that contains the name of the source file and the name of the function Here is an example of a progress message filename e main This type...

Страница 29: ...r 3 8 To invoke the code generator enter gspcg input file output file tempfile options gspcg is the command that invokes the code generator input file names the intermediate file that the code generator uses as input If you don t supply an extension the code generator assumes that the extension is if If you don t specify an input file the code generator will prompt you for one output file names th...

Страница 30: ...ll code model See Section 3 3 3 on the next page v produces code that can run in a multiprocess environ ment where all variables may be considered volatile Use this option when you compile modules that access vari ables which may be modified by another task process In general code generated this way is significantly less efficient x checks for overflow conditions of the runtime stack The C compile...

Страница 31: ...ode won t run You can verify that you conform to this limit by checking the link map 32K words translates to Ox80000 in bit addresses You can mix small model code with other code as long as the small model code conforms to the CALL restrictions For example if a module contains a group of functions that only call each other and the size of this compiled module is 32K words or less you can compile i...

Страница 32: ...ing Each Tool Individually 1 Invoke the preprocessor use program c for input gspcpp program C Pre Processor Version 3 xx c Copyright 1988 Texas Instruments Incorporated This creates an output file called program cpp 2 Invoke the parser use program cpp for input gspcc Jilrogram C Comp ler Version 3 xx c Copyright 1988 Texas Instruments Incor orated program c main This creates an output file called ...

Страница 33: ...atch file for example gspc filel file2 file Example 3 2 uses the gspc batch file to compile and assemble a C source file named program c You could also use gspq but it would not produce the messages shown in Example 3 2 Example 3 2 Method 2 Using the Batch File 3 12 gspc program program C Pre Processor Version 3 xx c Copyright 1988 Texas Instruments Incorporated C Compiler Version 3 xx c Copyright...

Страница 34: ...ibrary members that resolve undefined references For example you can link a C program consisting of modules progl prog2 and prog3 the output file is named prog out qsp1nk c proq1 proq2 prog3 1 rts 1ib 0 proq out The linker uses a default allocation algorithm to allocate your program into me mory You can use the MEMORY and SECTIONS directives to customize the allocation process For more information...

Страница 35: ...mmand File The command file first lists several linker options c is one of the options that can be used to link C code it tells the linker to use the ROM model of autoinitialization m tells the linker to create a map file the map file in this example is named example map 0 tells the linker to create an executable object module the module in this example is named example out Next the command file l...

Страница 36: ...he tables in memory When the program begins running the C boot routine copies data from the tables into the specified variables in the bss section This allows initialization data to be stored in ROM and then copied to RAM each time the program is started For more information about the ROM model see Section 5 8 2 2 on page 5 26 RAM Model cr linker option Global variables are initialized at load tim...

Страница 37: ... also allows you to manipulate a library by adding members to it or by extracting deleting or replacing members The TMS34010 Assembly Language Tools User s Guide contains complete instructions for using the archiver After compiling and assembling multiple files you can use the archiver to collect the object files into a library You can specify an archive file as linker input The linker is able to ...

Страница 38: ...n compares the C language compiled by the TMS3401 0 C compiler to the C language described by Kernighan and Ritchie It presents only the differences in the two forms of the C language The TMS3401 0 C compiler supports standard Kernighan and Ritchie C except as noted in this section Throughout this section references to Kernighan and Ritchie s Reference Manual Appendix A of The C Programming Langua...

Страница 39: ...e a long integer constant Combine the suffixes to declare an unsigned long integer constant Suffixes can be upper or lower case Here are some examples of integer constants 1234 int OxFFFFFFFFui unsigned int OLi lon9 int 077613LU uns gned long int K R 2 4 3 Character Constants In addition to the escape codes listed in K R the TMS3401 0 C compiler re cognizes the escape code v in character and strin...

Страница 40: ... be used in the same manner as an integer constant For more information about enumerators see Section 4 6 on page 4 8 K R 2 5 String Constants K R C does not limit the length of string constants however TMS34010 C limits the length of string constants to 255 bytes All characters after an embedded null byte in a string constant are ig nored in other words the first null byte terminates the string H...

Страница 41: ...ype that is a pointer to void void An object of type void can be converted to and from a pointer to an object of any other type without explicit conversions casts However such a pointer cannot be used indirectly to access the object that it points to without a conversion For example void p malloc char c int i p p p c i i malloc c i malloc p int p Legal Legal no cast needed Legal no cast needed Leg...

Страница 42: ... in any type definition However types can be combined using typedefs to pro duce any dimensioned array For example the following construction declares x as a four dimensional ar ray txpedef int dim2 i d m2 x i K R 2 6 Summary of TMS34010 Data Types Type Size char 8 bits signed ASCII unsigned char 8 bits ASCII short 16 bits unsigned short 16 bits int 32 bits unsigned int 32 bits long 32 bits unsign...

Страница 43: ... a function Signed objects of less than 32 bits are sign extended to 32 bits unsigned objects of less t an 32 bits are zero extended to 32 bits The type char is signed and is therefore sign extended when widened to in teger type Sign extension can be disabled by using the type unsigned char Types float and double are converted to type integer by truncation In K R C all floating point arithmetic is...

Страница 44: ...t as a separate statement or as the left operand of the comma operator Functions can be declared or typecast as void K R 7 1 Primary Expressions In TMS3401 0 C functions can return structures or unions The restriction of three array dimensions does not apply to expressions be cause is treated as an operator K R 7 2 Unary Operators in Expressions The value yielded by the sizeD operator is calculate...

Страница 45: ... be used with or without the word int the meaning is the same in either case The word unsigned can be used in conjunction with any integer type or alone if alone int is implied long float is a synonym for double Otherwise only one type specifier is allowed in a declaration R 8 4 Passing Returning Structures to from Functions o Contrary to K R TMS3401 0 C allows functions to return structures and u...

Страница 46: ...ated list of identifiers Each identifier can be followed by an equal sign and an integer constant If there is no enumerator followed by an sign and a value then the first enumerator is assigned the value 0 the next is 1 the next is 2 etc An identifier with an assigned value assumes that value the next enumerator is assigned that value 1 the next is the preceding value 1 etc The assigned value may ...

Страница 47: ...bss section SECTIONS bss OxOO 4 8 asm Statement A dditional Statement 4 10 TMS34010 C supports another statement that is not mentioned in K R the asm statement The compiler copies asm statements from the C source di rectly into the assembly language output file The syntax of the asm statement is asm assembly language statement The assembly language statement must be enclosed in double quotes All t...

Страница 48: ...not use the asm command to insert assembler directives which would change the assembly environment The asm command is very useful in the context of register variables A register variable is a variable in a C program that is declared by the user to reside in a nachine register TMS34010 C allows up to eight machine registers to be allocated to register variables These eight registers combined with t...

Страница 49: ...TMS34010 C Language ...

Страница 50: ...ssembly language functions that interface to C code follow the guidelines in this section Topics in this section include Section Page 5 1 Memory Model 5 2 5 2 Register Conventions 5 6 5 3 Function Structure and Calling Conventions 5 8 5 4 Interfacing C with Assembly Language 5 12 5 5 Interrupt Handling 5 16 5 6 Integer Expression Analysis 5 17 5 7 Floating Point Support 5 17 5 8 System Initializat...

Страница 51: ...age Tools User s Guide There are two basic types of sections Initialized sections contain data or executable code Uninitialized sections reserve space in memory usually RAM A program can use this space at run time for creating and storing variables The C compiler creates two initialized sections text and cinit it creates one uninitialized section bss The text section is an initialized section that...

Страница 52: ...ory for both stacks in the bss section This memory is allocated as a single static array named SYS STACK The boot routine defines a constant named STACK SIZE that determines the size of SYS STACK The default stack size is 2000 bytes You can change the amount of memory that is reserved for the stack by following these steps 1 Extract boot c from the source library rts src 2 Edit boot c change the v...

Страница 53: ... memory pool the default size is 1000 bytes You can change the size of the memory pool by following these steps 1 Extract memory c from the source library rts src 2 Edit memory c change the value of the constant MEMORY SIZE to the desired memory pool size 3 Recompile and assemble memory c and replace the resulting object file memory obj in the object library rts lib 4 Replace the copy of memory c ...

Страница 54: ... careful when you re defining structures or arrays of structures try to avoid defining fields that cross word boundaries If a structure is declared as an external or static variable it is always placed on a word boundary and is allocated space rounded up to a word boundary However when an array of structures is declared no rounding of size is used exactly enough space is allocated to hold each str...

Страница 55: ... 6 A function can usually use registers AO through A12 however When a function is called it must save the contents of each register that it uses it must restore these registers before it returns to the caller Re gister A8 is the only exception its contents do not have to be saved or restored If a function returns an integer value or a pointer the value must be placed in A8 The code generator uses ...

Страница 56: ...ables are declared the excess are treated as normal variables A register variable can contain any integer type a pointer to any type or a float doubles or structures are not allowed however register variables of type short and char are treated as long integers Using register variables can greatly increase code efficiency for some state ments in some cases the code may be twice as efficient Since t...

Страница 57: ...tion Call After Allocating Local Frame 5 3 1 Responsibilities of a Calling Function 5 8 A function performs the following tasks when it calls another function The steps below show examples of the code that the compiler might generate for a particular step For these code examples assume that a C function calls another function f that has three arguments the function call is f argl arg2 arg3 1 If th...

Страница 58: ...rform any cleanup after the function call 5 3 2 Responsibilities of a Called Function A called function must perform the following tasks The steps below show examples of the code that the compiler might generate for a particular step 1 If the function modifies any registers it saves them on the system stack If it uses the FP it must save it with the other registers If the called function must save...

Страница 59: ...double it can execute an RETS 0 instruction 5 3 3 Setting up the Local Frame In addition to the actions listed in Section 5 3 2 a called C function that has arguments or local variables must perform the following actions to setup the local frame These additional steps are performed immediately following step 1 above 1 It sets the new frame pointer to the current program stack pointer A14 MOVE STK ...

Страница 60: ...ock that the address points to This methods allows the caller to be smart about telling the called function where to return the structure For example consider the following statement s f where s is a structure and f is a function that returns a structure The caller can simply push the address of s onto the stack and call f Function f then copies the return structure directly into s performing the ...

Страница 61: ...more infor mation about interrupt handling see Section 5 5 page 5 16 4 If the caller passes arguments or if the called function returns a float or a double save the program stack pointer A14 by pushing it on the system stack then push any arguments on the program stack in reverse order 5 Functions must return values correctly according to their C declarations Integers and pointers are returned in ...

Страница 62: ... Language Function extern int aSIn func declare external asm function int gvar define global variable main int i j i aSIn func i FP STK set set global global global asIn func MMTM MOVE MOVE MOVE MOVE CALLA MOVE MOVE MMFM RETS a C Program A13 A14 gvar c_func asIn func SP A7 FP STK FP FP 32 A7 1 STK SP 1 g ar STK l c_func A8 A7 1 SP 96 STK 1 SP A7 FP 2 frame pointer program stack pointer declare glo...

Страница 63: ...ing variables in the bss section Example 5 2 a shows examples that use these three methods to define vari ables Example 5 2 b shows how you can use C code to access the first var iable defined in Example 5 2 a you can access the other variables similarly Example 5 2 Accessing an Assembly Language Variable from C 5 14 Method 1 Define variable var in the bss section bss var 32 global var Define the ...

Страница 64: ...xtremely careful not to dis rupt the C environment The compiler does not check or ana lyze the inserted instructions Inserting jumps or labels into the C code may produces unpre dictable results by confusing the register tracking algorithms that the code generator uses The asm statement is provided so that you can access features of the hardware which would be otherwise inaccessible from C Do not ...

Страница 65: ...nce it has no caller Interrupt routines for any interrupt except c intOO must save any register used with the exception of SP and STK including AB In a normal function it is not necessary to save AB however in the case of an interrupt AB must be saved The compiler uses the RETI instruction to return from an interrupt RETI restores the ST register of an interrupted function A C interrupt routine is...

Страница 66: ...ned on the stack Single precision values are converted to doubles when they are passed to functions Operations between two single precision oper ands are performed in single precision Operations between a single precision operand and a double precision operand are performed in double precision A custom package of floating point routines is included with the C compiler these functions do not follow...

Страница 67: ... e f is not a normalized floating point number If s O e O and f O the V 0 For all other cases V not valid Precision of single precision values is greater than six decimal digits the range includes Positive values 5 87747 x 10 39 to 1 70141 x 1038 Negative values 1 70141 x 1038 to 5 87747 x 10 39 0 oo 5 7 1 2 Double Precision Floating Point Format 63 62 Figure 5 4 illustrates the double precision f...

Страница 68: ...he stack dl is pushed first Function FD ADD FD SUB FD SUB R FD MUL FD DIV FD DIV R FD INC FD INCR FD DEC FD DECR FD GE FD LE FD GT FD LT FD EQ FD NE FD NEG FD ZERO Action Return dl d2 Return dl d2 Return d2 dl Return dl d2 Return dl d2 Return d2 dl Return dl 1 0 Return dl 1 0 Note dl is not popped Return dl 1 0 Return dl 1 0 Note dl is not popped Return dl d2 Return 1 or 0 in AS and set status Ret...

Страница 69: ...S ZERO Action Return f1 f2 Return f 1 f2 Return f2 f1 Return f1 f2 Return f1 f2 Return f2 f1 Return f1 1 0 Return f1 1 0 Note f1 is not popped Return f1 1 0 Return f 1 1 0 Note f 1 is not popped Return f1 f2 Return 1 or 0 in A8 and set status Return f1 f2 Return 1 or 0 in A8 and set status Return f1 f2 Return 1 or 0 in A8 and set status Return f1 f2 Return 1 or 0 in A8 and set status Return f1 f2 ...

Страница 70: ... to an unsigned integer and return in AS Convert f to double precision and return on stack Convert f to a signed integer and return in AS Convert f to an unsigned integer and return in AS Convert u to double precision and return on stack Convert i to double precision and return on stack Convert u to single precision and return on the stack Convert i to single precision and return on the stack 5 7 ...

Страница 71: ...les in bss Note that in the RAM initialization model a loader performs this step before the program runs it is not performed by the boot routine 3 Calls the function main to begin running the C program You can replace or modify the boot routine to meet your system requirements However the boot routine must perform the three operations listed above in order to correctly initialize the C environment...

Страница 72: ...a and initializing them with the data is called autoinitialization The compiler builds tables in a special section called cinit that contain data for initializing global and static variables Each compiled module contains these initialization tables The linker combines them into a single table a single cinit section that the boot routine uses to initialize all the variables that need values before ...

Страница 73: ...d It points to the variable s space in bss These first two fields are followed by one or more words of data During autoinitialization this data is copied to bss at the specified address Each variable that must be autoinitialized has an initialization re cord in the cinit section For example suppose that two initialized variables are defined in C as follows int i 23 int a 5 I 2 3 4 5 rhe initializa...

Страница 74: ...ker with the c option In this method global variables are initialized at run time The cinit section is loaded into memory possibly ROM along with all the other sections The linker defines a special symbol called cinit that points to the beginning of the initialization tables in memory When the program begins running the C boot routine copies data from the tables pointed to by cinit into the spe ci...

Страница 75: ...rmally cinit would point to the beginning of the initialization tables This indicates to the boot routine that the initialization tables are not present in memory accordingly no runtime in itialization is performed at boot time Note that you must use a smart loader to take advantage of the RAM model When the program is loaded the loader must be able to Detect the presence of the cinit section in t...

Страница 76: ... this section the library rts src contains the source to these functions as well as to other functions and routines If you use any of the runtime support functions be sure to include rts lib as linker input when you link your C program This section is divided into three parts Part 1 describes header files and discusses their functions Part 2 summarizes the runtime support functions according to ca...

Страница 77: ...n 6 1 1 through Section 6 1 10 describe the header files that are in cluded with the TMS34010 C compiler Section 6 2 page 6 9 lists the functions that these headers declare 6 1 1 Diagnostic Messages assert h 6 2 The assert h header defines the assert macro which inserts diagnostic fail ure messages into programs at runtime The assert macro tests a runtime ex pression If the expression is true the ...

Страница 78: ... as the corresponding functions but each macro is prefixed with an underscore for example isdigit 6 1 3 Limits float h and limits h The float h and limits h headers define macros that expand to useful limits and parameters of the TMS3401 O s numeric representations Table 6 1 and Table 6 2 list these macros and the limits they are associated with Table 6 1 Macros that Supply Integer Type Range Limi...

Страница 79: ... in the range of normalized floats DBL DIG 15 Number of decimal digits of precision for a double or LDBL DIG a long double DBL MANT DIG 52 Number of base FLT RADIX digits in the mantissa LDBL MANT DIG of a double or a long double DBL MIN EXP 1022 Smallest exponent base 2 for a double or long double LDBL MIN EXP DBL MAX EXP 1023 Largest exponent base 2 for a double or long double LDBL MAX EXP DBL E...

Страница 80: ...cros EDOM for domain errors invalid parameter or ERANGE for range errors invalid result C code that calls a math function can read the value of errno to check for error conditions The errno variable is declared in errno h and defined in errno c When a function produces a floating point return value that is too large to be represented it returns HUGE VAL instead 6 1 5 Nonlocal Jumps setjmp h The se...

Страница 81: ... ptrdiff t a signed integer type that is the data type resulting from the subtraction of two pointers and size t an unsigned integer type that is the data type of the sizeof oper ator The macros include The NULL macro which expands to a null pointer constant O and The offsetof type identifier macro which expands to an integp r that has type size to The result is the value of an offset in bytes to ...

Страница 82: ...s that allow your program to terminate normally or abnormally Integer arithmetic that is not provided as a standard part of the C lan guage 6 1 9 String Functions string h The str ing h header declares standard functions that allow you to perform the following tasks with character arrays strings Move or copy entire strings or portions of strings Concatenate strings Compare strings Search strings f...

Страница 83: ...ime t an arithmetic type that represents time and struct tm is a structure that holds the components of calendar time called broken down time The structure has the following members int tm sec seconds after the minute 0 59 int tm min minutes after the hour 0 59 int tm hour hours after midnight 0 23 int tm mday day of the month 1 31 int tm mon months since January 0 11 int tm year years since 1900 ...

Страница 84: ... ASCII character int isprint c Tests c to see if it s a printable ASCII character char c including spaces int ispunct c Tests c to see if it s an ASCII punctuation character char C int isspace c Tests c to see if it s an ASCII spacebar tab horizontal char C or vertical carriage return formfeed and newline characters int isupper c Tests c to see if it s an uppercase ASCII alphabetic char Ci charact...

Страница 85: ...rns the natural logarithm of a real number x double x double loglO x Returns the base 1 0 logarithm of a real number x double x double modf value iptr Breaks a floating point number into into a signed integer and double value a signed fraction int iptr double pow x y double x y Returns x raised to the power y double sin x Returns the sine of a floating point value x double x double sinh x Returns ...

Страница 86: ...of j long int j Idiv_t Idiv numer denom long int numer denom Divides numer by denom int Itoa n buffer Converts n to the equivalent ASCII string long n char buffer void malloc size Allocates memory for an object of size bytes size t size void minit Resets all the memory previously allocated by malloc calloc or realloc char movmem src dest count char src dest int count Moves count bytes from one add...

Страница 87: ...har 51 52 0 if 51 is less than 52 0 if 51 is equal to 52 0 if 51 is greater than 52 int strcoll 51 52 Compares strings and returns one of the following values char 51 52 depending on the locale in the program 0 if 51 is less than 52 0 if 51 is equal to 52 0 if 51 is greater than 52 char strcpY 51 52 Copies string 52 into 51 char 51 52 5ize t strcspn 51 52 Returns the length of the initial segment ...

Страница 88: ...me h Function and Syntax Description char asctime timeptr Converts a time to a string struct tm timeptr c1ock_t clock Determines the processor time used char ctime timeptr Converts calendar time to local time struct tm timeptr double difftime time1 timeO Returns the difference between two calendar times time_t time1 timO struct tm gmtime timer Converts calendar time Greenwich Mean Time time t time...

Страница 89: ...ions reference Function Page abort 6 16 abs 6 17 acos 6 18 asctime 6 19 asin 6 20 assert 6 21 atan 6 22 atan2 6 23 atexit 6 24 atof 6 25 atoi 6 25 atol 6 25 bsearch 6 26 calloc 6 27 ceil 6 28 clock 6 29 cos 6 30 cosh 6 31 ctime 6 32 difftime 6 33 div 6 34 exit 6 35 exp 6 36 fabs 6 37 floor 6 38 fmod 6 39 free 6 40 frexp 6 41 gmtime 6 42 isalnum 6 43 isalpha 6 43 isascii 6 43 iscntrl 6 43 isdigit 6...

Страница 90: ... 6 61 realloe 6 62 sin 6 63 sinh 6 64 sqrt 6 65 srand 6 61 streat 6 66 strehr 6 67 stremp 6 68 streoll 6 69 strepy 6 69 strespn 6 70 strerror 6 71 strftime 6 72 strlen 6 73 strneat 6 74 strnemp 6 75 strnepy 6 76 strpbrk 6 77 strrehr 6 78 strspn 6 79 strstr 6 80 strtod 6 81 strtok 6 82 strtol 6 81 strtoul 6 81 tan 6 83 tanh 6 84 time 6 85 toaseii 6 86 tolower 6 87 toupper 6 87 va arg 6 88 va end 6 ...

Страница 91: ...escription The abort function usually terminates a program with an error code The TMS34010 implementation of the abort function calls the exit function with a value of 0 and is defined as follows void abort exit O This makes the abort function functionally equivalent to the exit function 6 16 ...

Страница 92: ... compiler supports two functions that return the absolute value of an integer The abs function returns the absolute value of an integer j The labs function returns the absolute value of a long integer k Since int and long int are functionally equivalent types in TMS3401 0 C the abs and labs functions are also functionally equivalent 6 17 ...

Страница 93: ...uble X asin obj in rts lib Arc Cosine The acos function returns the arc cosine of a floating point argument x X must be in the range 1 1 The return value is an angle in the range O n radians double realval radians realval 1 0 radians acos rea1va1 i return radians acos returns n 2 ...

Страница 94: ...src asctime Description The asctime function converts a broken down time into a string with the following form Mon Jan 11 11 18 36 1988 n O The function returns a pointer to the converted string For more information about the functions and types that the time h header declares see Section 6 1 10 on page 6 7 6 19 ...

Страница 95: ...sin obj in rts lib Description The asin function returns the arc sine of a floating point argument x X must be in the range 1 1 The return value is an angle in the range n 2 n 2 radians Example double realval radians realval 1 0 radians asin realval i asin returns n 2 6 20 ...

Страница 96: ... true the assert macro does nothing The header file that declares the assert macro refers to another macro NDEBUG If you have defined NDEBUG as a macro name when the as sert h header is included in the source file then the assert macro is de fined as define assert ignore If NDEBUG is not defined when assert h is included then the assert macro is defined as define assert expr if expr printf Asserti...

Страница 97: ...tan obj in rts lib Polar Arc Tangent Description The atan function returns the arc tangent of a floating point argument x The return value is an angle in the rang n 2 n 2 radians Exalnple double realval radians realval 0 0 radians atan realval return value a 6 22 ...

Страница 98: ...function returns th inverse tangent of y Ix The function uses the signs of the arguments to determine the quadrant of the return value Both arguments cannot be O The return value is an angle in the range rr rr radians EXBlnpie double rvalu rvalv double radians rvalu rvalv radians 0 0 1 0 atan2 rvalr rvalu i 1 return value a 1 6 23 ...

Страница 99: ...exit function registers the function that is pointed to by fun to be called without arguments at normal program termination Up to 32 func tions can be registered 6 24 When the program exits through a call to the exit function the functions that were registered are called without arguments in reverse order of their registration ...

Страница 100: ... space sign digits The atol function converts a string to a long integer Argument nptr points to the string the string must have the following format space sign digits The space is indicated by a space from the space bar a horizontal or ver tical tab a carriage return a form feed or a newline Following the space is an optional sign and then digits that represent the integer portion of the number T...

Страница 101: ...tes of each member 6 26 The contents of the array must be in ascending sorted order If a match is found the function returns a pointer to the matching member of the array if no match is found the function returns a null pointer 0 Argument cornpar points to a function that compares key to the array el ements The comparison function should be declared as int cmp ptrl ptr2 void ptrl ptr2 The cmp func...

Страница 102: ... memory that is if it runs out of memory it returns a null pointer 0 Example The memory that calloc uses is in a special memory pool or heap A C module called memory c reserves memory for the heap in the bss section The constant MEMORY SIZE defines the size of the heap as 1000 bytes If necessary you can change the size of the heap by change the value of MEMORY SIZE and reassembling memory c For mo...

Страница 103: ...n floor obj in rts lib Ceiling Description The ceil function returns a double precision number that represents the smallest integer greater than or equal to x Example extern double ceil 6 28 double answeri answer ceil 3 1415 answer 4 0 answer ceil 3 5 answer 3 0 ...

Страница 104: ...acro CLK TCK If the processor time is not available or cannot be represented the clock function returns the value of clock t 1 Note The clock function is target system specific so you must write your own clock function You must also define the CLK TCK macro ac cording to the granularity of your clock so that the value returned by clock number of clock ticks can be divided by CLK TCK to pro duce a ...

Страница 105: ...n rts lib Cosine The cos function returns the cosine of a floating point number x x is an angle expressed in radians An argument with a large magnitude may produce a result with little or no significance double radians cval radians 3 1415927 eval eos radians i cos returns cval return value 1 0 ...

Страница 106: ...double X Defined in sinh obj in rts lib cosh DescriptiQn The cosh function returns the hyperbolic cosine of a floating point number x A range error occurs if the magnitude of the argument is too large Example double x y x 0 0 y cosh x return value 1 0 6 31 ...

Страница 107: ... calendar time pointed to by timer to local time in the form of a string This is equivalent to 6 32 asctime localtime timer The function returns the pointer returned by the asctime function with that broken down time as an argument For more information about the functions and types that the time h header declares see Section 6 1 10 on page 6 7 ...

Страница 108: ... in difftime c in rts src difftime Description The difftime function calculates the difference between two calendar times timel minus timeO The return value expresses seconds For more information about the functions and types that the time h header declares see Section 6 1 10 on page 6 7 6 33 ...

Страница 109: ...e div t The structure is defined as follows typedef struct int quot int rem div_t quotient remainder The Idiv function performs long integer division The input argu ments are long integers the function returns the quotient and the re mainder in a structure of type Idiv t The structure is defined as follows typedef struct long int quot long int rem ldiv ti quotient remainder If the division produce...

Страница 110: ... status Defined in exit c in rts src exit Description When a program exits through a call to the exit function the atexit function calls the functions without arguments that were registered in reverse or der of their registration The exit function does return 6 35 ...

Страница 111: ...rts lib Exponential Description The exp function returns the exponential function of real number x The return value is the number e raised to the power x A range error occurs if the magnitude of x is too large Example double x y x 2 0 Y exp x i y 7 38 which is e 2 0 6 36 ...

Страница 112: ...x include math h double fabs x double X Defined in fabs obj in rts lib fabs Description The fabs function returns the absolute value of a floating point number x Example double x y x 57 5 Y fabs x i return value 57 5 6 37 ...

Страница 113: ...X Defined in floor obj in rts lib Floor Description The floor function returns a double precision number that represents the largest integer less than or equal to x Exar nple double answer 6 38 answer floor 3 14IS answer 3 0 answer floor 3 S answer 4 0 ...

Страница 114: ...double fmod x y double x Yi Defined in fmod obj in rts lib fmod Description The fmod function returns the floating point remainder of x divided by y If y O the function returns O Exalnple double x y ri x 11 0 i Y 5 0 r fmod x y fmod returns 1 0 6 39 ...

Страница 115: ...s previously allocated by a malloc calloc or realloc call This makes the memory space available again If you attempt to free unallocated space the function takes no action and returns For more information see Section 5 1 3 Dynamic Memory Allocation on page 5 4 Example This example allocates 10 bytes and then frees them 6 40 char x x malloc lO free x allocate 10 bytes free 10 bytes ...

Страница 116: ...function breaks a floating point number into a normalized fraction and an integer power of 2 The function returns a value with a magnitude in the range 1 or 0 so that value x x 2 exp The frexp function stores the power in the int pointed to by expo If value is 0 both parts of the result are 0 Example double fraction int exp fraction frexp 3 0 exp after execution fraction is 75 and exp is 2 6 41 ...

Страница 117: ...fined in gmtime c in rts src Description The gmtime function converts a calendar time pointed to by timer into a broken down time which is expressed as Greenwich Mean Time 6 42 For more information about the functions and types that the time h header declares see Section 6 1 10 on page 6 7 ...

Страница 118: ...ph islower isprint ispunct isspace isupper isxdigit for which isalpha or isdigit is true identifies alphabetic ASCII characters tests for any character for which islower or isupper is true identifies ASCII characters any character between 0 127 identifies control characters ASCII character 0 31 and 127 identifies numeric characters 0 9 identifies any non space character identifies lowercase alphab...

Страница 119: ...xp obj in rts lib Description The Idexp function multiplies a floating point number by a power of 2 and returns X x 2exP exp can be a negative or a positive value A range error may occur if the result is too large Exan1ple double result 6 44 result ldexp l 5 5 result is 48 0 result ldexp 6 0 3 result is 0 75 ...

Страница 120: ...src Description The local time function converts a calendar time pointed to by timer into a broken down time which is expressed as local time The function returns a pointer to the converted time For more information about the functions and types that the time h header declares see Section 6 1 10 on page 6 7 6 45 ...

Страница 121: ...ned in log obj c in rts lib Natural Logarithm Description The log function returns the natural logarithm of a real number x A do main error occurs if x is negative a range error occurs if x is O Example float x y 6 46 x 2 718282 Y log x Return value 1 0 ...

Страница 122: ...x double Xi Defined in log obj c in rts lib log10 Description The log10 function returns the base 10 logarithm of a real number x A domain error occurs if x is negative a range error occurs if x is O Example float x y x 10 0 Y log x Return value 1 0 6 47 ...

Страница 123: ...t char bufferi buffer to put result in Defined in 1toa c in rts src Description The Itoa function converts a long integer to the equivalent ASCII string If the input number n is negative a leading minus sign is output The Itoa function returns the number of characters placed in the buffer 6 48 ...

Страница 124: ...s out of memory it returns a null pointer 0 This function does not modify the memory it allocates The memory that malloc uses is in a special memory pool or heap A C module called memory c reserves memory for the heap in the bss section The constant MEMORY SIZE defines the size of the heap as 1000 bytes If necessary you can change the size of the heap by change the value of MEMORY SIZE and reassem...

Страница 125: ...on The memchr function finds the first occurrence of c in the first n characters of the object that s points to If the character is found memchr returns a pointer to the located character otherwise it returns a null pointer 0 6 50 The memchr function is similar to strchr except the object that memchr searches can contain values of 0 and c can be O ...

Страница 126: ...function compares the first n characters of the object that 52 points to with the object that 51 points to The function returns one of the following values 0 if 51 is less than 52 o if 51 is equal to 52 0 if 51 is greater than 52 The memcmp function is similar to strncmp except the objects that memcmp compares can contain values of O 6 51 ...

Страница 127: ...The memcpy function copies n characters from the object that s2 points to into the object that s 1 points to If you attempt to copy characters of overlapping objects the function s behavior is undefined The function re turns the value of sl 6 52 The memcpy function is similar to strncpy except the objects that memcpy copies can contain values of O ...

Страница 128: ...size t n Defined in memmov c in rts src memmove Description The memmove function moves n characters from the object that s2 points to into the object that s1 points to the function returns the value of 5 l The memmove function correctly copies characters between overlapping objects 6 53 ...

Страница 129: ...et s c n void s char c size t n Defined in memset c in rts src Duplicate Value in Memory Description The memset function copies the value of c into the first n characters of the object that s points to The function returns the value of s 6 54 ...

Страница 130: ...eap available again Any objects that you allocated previously will be lost don t try to access them The memory that minit uses is in a special memory pool or heap A C mo dule called memory c reserves memory for the heap in the bss section The constant MEMORY SIZE defines the size of the heap as 1000 bytes If nec essary you can change the size of the heap by change the value of MEMORY_SIZE and reas...

Страница 131: ...e final value of tm mday is not sent until tm mon and tm year are determined The return value is encoded as a value of type time to If the calendar time cannot be represented the function returns the value 1 This example determines the day of the week that July 4 2001 falls on include time h static const char const wday Sunday Monday Tuesday Wednesday Thursday Friday Saturday struct tm time str ti...

Страница 132: ... a value into a signed integer and a signed frac tion Each of the two parts has the same sign as the input argument The function returns the fractional part of value and stores the integer as a double at the object pointed to by iptr EX8lnple double value ipart fpart value 3 1415 fpart modf va1ue ipart After execution ipart contains 3 0 and fpart contains 0 1415 6 57 ...

Страница 133: ...est count char src source address char dest destination address char count number of bytes to move movmem c in rts src The movmem function moves count bytes of memory from the object that src points to into the object that dest points to The source and desti nation areas can be overlapping ...

Страница 134: ... power Y Defined in pow obj in rts lib pow Description The pow function returns x raised to the power y A domain error occurs if x o and ySO or if x is negative and y is not an integer A range error may occur Example double x I y I Z x 2 0 Y 3 0 Z pow x y return value 8 0 6 59 ...

Страница 135: ...rted array argument size specifies the size of each member 6 60 This function sorts the array in ascending order Argument compar points to a function that compares key to the array el ements The comparison function should be declared as int cmp ptrl ptr2 void ptrl ptr2 The cmp function compares the objects that ptrl and ptr2 point to and returns one of the following values 0 if ptrl is less than p...

Страница 136: ...om integers in the range Q RAN D MAX The srand function sets the value of seed so that a subsequent call to the rand function produces a new sequence of pseudo random numbers The srand function does not return a value If you call rand before calling srand rand generates the same sequence it would produce if you first called srand with a seed value of 1 If you call srand with the same seed value ra...

Страница 137: ...ted the original memory space is not changed and realloc returns O If size O and ptr is not null then realloc frees the space that ptr points to If in oreler to allocate more space the entire object must be moved realloc returns a pointer to the new space Any memory freed by this operation is deallocated If an error occurs the function returns a null pointer 0 The memory that realloc uses is in a ...

Страница 138: ... lib sin The sin function returns the sine of a floating point number x X is an angle expressed in radians An argument with a large magnitude may pro duce a result with little or no significance double radian sval sval is returned by sin radian 3 1415927 sva1 sin radian 1 is returned by sin 6 63 ...

Страница 139: ...fined in sinh obj in rts lib Hyperbolic Sine Description The sinh function returns the hyperbolic sine of a floating point number x A range error occurs if the magnitude of the argument is too large Example double X y X 0 0 y sinh x return value 0 0 6 64 ...

Страница 140: ...qrt x double X Defined in sqrt obj in rts lib sqrt Description The sqrt function returns the nonnegative square root of a real number x A domain error occurs if the argument is negative Example double X y X 100 0 Y sqrt x return value 10 0 6 65 ...

Страница 141: ...t c in rts src Concatenate Strings Description The strcat function appends a copy of s2 to including a terminating null character to the end of s1 The initial character of s2 overwrites the null character that originally terminated s 1 The function returns the value of s1 6 66 ...

Страница 142: ... s c char s char c Defined in strchr c in rts src strchr Description The strchr function finds the first occurrence of c which is first converted to a char in s If strchr finds the character it returns a pointer to the character otherwise it returns a null pointer 0 6 67 ...

Страница 143: ...c in rts src String Compare Description The strcmp and strcoll functions compare s2 with s 1 The functions are equivalent both functions are supported to provide compatibility with ANSI C The functions return one of the following values 0 if s1 is less than s2 o if s1 is equal to s2 0 if s1 is greater than s2 6 68 ...

Страница 144: ...efined in strcpy c in rts src strcpy Description The strcpy function copies s2 including a terminating null character into s1 If you attempt to copy strings that overlap the function s behavior is undefined The function returns a pointer to the destination string 6 69 ...

Страница 145: ... size t strcspn sl s2 char sl s2 Defined in strcspn c in rts src Description The strcspn function returns the length of the initial segment of sl which is entirely made up of characters that are not in s2 If the first character in sl is in s2 the function returns O 6 70 ...

Страница 146: ...ror Syntax Defined in Description include string h char strerror errnum int errnum strerror c in rts src The strerror function returns the string function error This function is supplied to provide ANSI compatibility 6 71 ...

Страница 147: ...cale s full month name c the locale s appropriate date and time representation d the day of the month as a decimal number 0 31 H the hour 24 hour clock as a decimal number 00 23 1 the hour 12 hour clock as a decimal number 01 12 j the day of the year as a decimal number 001 366 m the month as a decimal number 01 12 M the minute as a decimal number 00 59 p the locale s equivalent of either AM or PM...

Страница 148: ...ar s Defined in strlen c in rts src strlen Description The strlen function returns the length of s In C a character string is ter minated by the first byte with a value of 0 a null character The returned result does not include the terminating null character 6 73 ...

Страница 149: ...tenate Strings Description The strncat function appends up to n characters of s2 including a termi nating null character to the end of 51 The initial character of 52 over writes the null character that originally terminated 51 strncat appends a null character to result The function returns the value of s1 6 74 ...

Страница 150: ... string h int strncmp sl s2 n char s1 s2 size t nj strncmp c in rts src The strncmp function compares up to n characters of s2 with s1 The function returns one of the following values 0 if s1 is less than s2 o if s1 is equal to s2 0 if s1 is greater than s2 6 75 ...

Страница 151: ...n characters from s2 into s1 If s2 is n characters long or longer the null character that terminates s2 is not co pied If you attempt to copy characters from overlapping strings the func tion s behavior is undefined If s2 is shorter than n characters strncpy appends null characters to s1 so that s1 contains n characters The func tion returns the value of s1 6 76 ...

Страница 152: ...l s2 char sl s2 Defined in strpbrk c in rts src strpbrk Description The strpbrk function locates the first occurrence in s 1 of any character in s2 If strpbrk finds a matching character it returns a pointer to that char acter otherwise it returns a null pointer 0 6 77 ...

Страница 153: ...ude string h char strrehrCs e char s int c Defined in strrchr c in rts src Description The strrchr function finds the last occurrence of c in s If strrchr finds the character it returns a pointer to the character otherwise it returns a null pointer 0 6 78 ...

Страница 154: ...t strspn sl s2 int sl s2 Defined in strspn c in rts src strspn Description The strspn function returns the length of the initial segment of s 1 which is entirely made up of characters in s2 If the first character of s1 is not in s2 the strspn function returns O 6 79 ...

Страница 155: ...escription The strstr function finds the first occurrence of s2 in s 1 excluding the ter minating null character If strstr finds the matching string it returns a pointer to the located string if it doesn t find the string it returns a null pointer If s2 points to a string with length 0 then strstr returns s1 6 80 ...

Страница 156: ... original string is empty or does not have the correct format the function returns a O If the converted string would cause an overflow the function returns HUGE VAL if the converted string woul d cause an underflow the function returns O If the converted string causes an overflow or an underflow errno is set to the value of ERANGE The strtol function converts a string to a long integer The string ...

Страница 157: ...l s2 char sl s2 Defined in strtok c in rts src Break String into Tokens Description Successive calls to the strtok function break s1 into a series of tokens each delimited by a character from s2 Each call returns a pointer to the next token 6 82 ...

Страница 158: ...rts lib tan Description The tan function returns the tangent of a floating point number x X is an angle expressed in radians An argument with a large magnitude may produce a result with little or no significance Example double x y X 3 1415927 4 0 y tan x return value 1 0 6 83 ...

Страница 159: ...th h double tanh x double X Defined in tanh obj in rts lib Hyperbolic Tangent Description The tanh function returns the hyperbolic tangent of a floating point num ber x Example double X y x 0 0 y tanh x return value 0 0 6 84 ...

Страница 160: ...nds If the calendar time is not available the function returns 1 If timer is not a null pointer the function also assigns the return value to the object that timer points to For more information about the functions and types that the time h header declares see Section 6 1 10 on page 6 7 Note The time function is target system specific so you must write your own time function 6 85 ...

Страница 161: ...de ctype h int toascii c char c Defined in toascii c in rts src Convert to ASCII Description The toascii function ensures that c is a valid ASCII character by masking the lower seven bits There is also a toascii macro 6 86 ...

Страница 162: ...rt the case of a single alphabetic character c to upper or lower case The tolower function converts an uppercase argument to lowercase If c is already in lowercase tolower returns it unchanged The toupper function converts a lowercase argument to uppercase If c is already in uppercase toupper returns it unchanged The functions have macro equivalents named tolower and toupper 6 87 ...

Страница 163: ...lared list The va arg macro returns the value of the next argument in a call to a variable argument function Each time you call va arg it modifies ap so that successive arguments for the variable argument function can be returned by successive calls to va arg va arg modifies ap to point to the next argument in the list The type parameter is a type name it is the type of the current argument in the...

Страница 164: ...source The compiler cannot find the file name as entered Check for spelling errors and check to see that the named file actually exists can t open filename as intermediate file The compiler cannot create the output file This is usually caused byei ther an error in the syntax of the filename or a full disk illegal extension ext on output file The intermediate file cannot have a c extension fatal er...

Страница 165: ...Appendix A Error Messagess A 2 ...

Страница 166: ...s that the preprocessor supports Generally the directives are organized alphabetically one directive per page however related directives such as if else are presented together on one page Here s an alphabetical table of contents for the preprocessor directives reference Directive Page define 8 2 else 8 3 endif 8 3 if 8 3 ifdef 8 3 ifndef 8 3 include 8 5 Iine 8 6 undef 8 2 B 1 ...

Страница 167: ...ith arguments is expanded the arguments are placed into the expanded token string unchanged After the entire token string is expanded the preprocessor scans again for names to expand at the beginning of the newly created token string which allows for nested macros Note that there is no space between name and the open parenthesis at the beginning of the argument list A trailing semicolon is not re ...

Страница 168: ...pression The precedence of the operators is the same as in the definition of the C language The preprocessor also supports a unary operator named de fined which can be used in constant expression in one of two forms 1 defined name or 2 def ined name This allows the the utility of ifdef and ifndef in an if directive Only these operators integer constants and names which are known by the preprocesso...

Страница 169: ...by ifdef is not defined The name tested by ifndef is defined Note that the else portion of a conditional block is optional if the if ifdef or ifndef test is not successful then the preprocessor continues with the code following the endif The endif directive ends a conditional block Each if ifdef and ifndef directive must have a matching endif Conditional compila tion sequences can be nested ...

Страница 170: ...ion and you enclose the filename in double quotes the preprocessor searches for the file in 1 The directory that contains the current source file The current source file refers to the file that is being processed when the preprocessor encounters the include directive 2 Any directories named with the i preprocessor option 3 Any directories named with the C DIR environment variable i If you do not p...

Страница 171: ...mation for the next pass of the compiler The integer constant is the line number of the next line and the filename is the file where that line exists If you do not provide a filen ame the current filename specified by the last line directive is un changed This directive effectively sets the __LINE __ and __ FILE __ symbols B 6 ...

Страница 172: ...3 16 batch files 3 11 3 12 boot obj 3 13 3 15 broken down time 6 8 bsearch function 6 26 c c preprocessor option 3 2 C compiler 1 3 c option linker 3 13 3 16 calendar time 6 8 calloc function 6 27 Index C DIR environment variable 3 4 3 6 ceil function 6 28 character constants 4 2 character conversions 4 6 character typing conversion functions 6 3 6 9 isalnum 6 43 isalpha 6 43 isascii 6 43 iscntrl ...

Страница 173: ...nts 4 2 environment variable 3 4 EPROM programmers 1 3 ERANGE macro 6 5 error messages A 1 exit function 6 35 Index 2 exp function 6 36 explicit pointer conversions 4 7 F fabs function 6 37 fatal errors A 1 field manipulation 5 5 float h header 6 3 6 4 floating point constants 4 2 floating point conventions 5 17 floating point conversions 4 6 floating point math functions 6 5 6 9 acos 6 18 asin 6 ...

Страница 174: ...instruction set 1 4 integer constants 4 2 integer conversions 4 6 integer expression analysis 5 17 integer return values 5 6 interfacing C with assembly language 5 12 assembly language modules 5 12 defining variables in assembly lan guage 5 14 interrupt handling 5 16 invoking batch files 3 12 invoking the assembler 3 11 batch files 3 11 code generator 3 8 linker 3 13 parser 3 6 preprocessor isalnu...

Страница 175: ...9 minit 6 55 movmem 6 58 realloc 6 62 memory model 5 2 memset function 6 54 minit function 6 55 mktime function 6 56 modf 6 57 modf function 6 57 movmem function 6 58 Index 4 N NDE8UG macro 6 21 6 2 nonlocal jump functions 6 5 NULL macro 6 6 o 0 code generator option 3 9 object alignment 4 6 object format converter 1 3 object libraries 3 13 offsetof macro 6 6 operation of the compiler 3 1 3 16 p p...

Страница 176: ...nt board 1 4 software installation 2 1 SP 5 3 sqrt function 6 65 srand function 6 61 stacks 5 3 static variables stdarg h header stddef h header stdlib h header STK 5 3 4 10 6 6 6 10 6 6 6 6 6 11 strcat function 6 66 strchr function 6 67 strcmp function 6 68 strcoll function 6 68 strcpy function 6 69 strcspn function 6 70 strerror function 6 71 strftime function 6 72 string functions 6 7 memchr 6 ...

Страница 177: ...me t type 6 8 tm structure 6 8 TMS34010 C language 4 1 toascii macro 6 86 toascii 6 86 tolower function 6 87 toupper function 6 87 tolower 6 87 toupper 6 87 u Ultrix installation 2 4 undef directive 8 2 unions 4 7 Index 6 v v code generator option 3 9 va arg macro 6 88 va end function 6 88 va list type 6 6 variable argument functions 6 6 6 88 directives define B 2 else 8 3 endif 8 3 if 8 3 ifdef 8...

Страница 178: ... with the C programming language before you used the TMS3401 0 C compiler Are the references to other C Ianguage documentation Le Kernighan and Ritchie adequate What kinds of examples would you like us to include in this manual How would you change this manual to make it more accurate or easier to use What information would you add to or delete from the Reference Card Additional comments Thank you...

Страница 179: ...OUSTON TEXAS POSTAGE WILL BE PAID BY ADDRESSEE Product Documentation Services Manager Texas Instruments Incorporated P O Box 1443 MIS 640 Houston Texas 77251 9879 11 11 1 1 1 1 1 11111 1 1 1 1 11 1 1 1 1 NO POSTAGE NECESSARY IF MAILED IN THE UNITED STATES ...

Страница 180: ......

Страница 181: ...Printed in U S A August 1988 1604903 9704 1 TEXAS INSTRUMENTS SPVU005A ...

Отзывы: