HI-TECH C PRO for the PSoC Mixed-Signal Array HI-TECH Software Copyright (C) 2008 HI-TECH Software All Rights Reserved Printed in Australia PSoC and Cypress are registered trademarks of Cypress Semiconductor Corp Produced on: October 22, 2008 HI-TECH Software Pty Ltd ACN 002 724 549 45 Colebard Street West Acacia Ridge QLD 4110 Australia email: hitech@htsoft.com web: http://cypress.htsoft.com ftp: ftp://www.htsoft.com Contents Table of Contents List of Figures 17 List of Tables 19 Introduction 21 1.1 Typographic conventions 21 CPSOC Command-line Driver 2.1 Invoking the Compiler 2.1.1 Long Command Lines 2.2 The Compilation Sequence 2.2.1 Single-step Compilation 2.2.2 Generating Intermediate Files 2.2.3 Special Processing 2.2.3.1 Printf check 2.2.3.2 Assembly Code Requirements 2.3 Runtime Files 2.3.1 Library Files 2.3.1.1 Standard Libraries 2.3.2 Runtime Startup Module 2.3.2.1 Initialization of Data psects 2.3.2.2 Clearing the Bss Psects 2.3.3 The Powerup Routine 2.3.4 The printf Routine 2.4 Debugging Information 2.4.1 Output File Formats 23 24 25 26 27 28 29 30 30 30 31 32 32 33 34 34 35 37 37 CONTENTS 2.5 2.6 CONTENTS 2.4.2 Symbol Files 2.4.3 Support Files Compiler Messages 2.5.1 Messaging Overview 2.5.2 Message Language 2.5.3 Message Type 2.5.4 Message Format 2.5.5 Changing Message Behaviour 2.5.5.1 Disabling Messages 2.5.5.2 Changing Message Types CPSOC Driver Option Descriptions 2.6.1 -C: Compile to Object File 2.6.2 -Dmacro: Define Macro 2.6.3 -Efile: Redirect Compiler Errors to a File 2.6.4 -Gfile: Generate source-level Symbol File 2.6.5 -Ipath: Include Search Path 2.6.6 -Llibrary: Scan Library 2.6.7 -L-option: Adjust Linker Options Directly 2.6.8 -Mfile: Generate Map File 2.6.9 -Nsize: Identifier Length 2.6.10 -Ofile: Specify Output Filenames 2.6.11 -P: Preprocess Assembly Files 2.6.12 -Q: Quiet Mode 2.6.13 -S: Compile to Assembly Code 2.6.14 -Umacro: Undefine a Macro 2.6.15 -V: Verbose Compile 2.6.16 -X: Strip Local Symbols 2.6.17 ASMLIST: Generate Assembly List Files 2.6.18 AUTOBANK=number: Specify Local Variable Bank 2.6.19 CHAR=type: Make Char Type Signed or Unsigned 2.6.20 CHECKSUM=start-end@destination: Calculate a checksum 2.6.21 CHIP=processor: Define Processor 2.6.22 CHIPINFO: Display a list of supported processors 2.6.23 CR=file: Generate Cross Reference Listing 2.6.24 DOUBLE=type: Select kind of Double Types 2.6.25 ERRFORMAT=format: Define Format for Compiler Messages 2.6.26 ERRORS=number: Maximum Number of Errors 2.6.27 FILL=opcode: Fill Unused Program Memory 37 37 38 38 39 40 40 43 43 44 44 46 47 47 48 48 49 49 51 51 51 52 52 52 52 53 53 53 53 54 54 54 55 55 55 56 56 56 CONTENTS 2.6.28 2.6.29 2.6.30 2.6.31 2.6.32 2.6.33 2.6.34 2.6.35 2.6.36 2.6.37 2.6.38 2.6.39 2.6.40 2.6.41 2.6.42 2.6.43 2.6.44 2.6.45 2.6.46 2.6.47 2.6.48 2.6.49 2.6.50 2.6.51 2.6.52 2.6.53 2.6.54 2.6.55 2.6.56 2.6.57 2.6.58 2.6.59 CONTENTS GETOPTION=app,file: Get command line options HELP: Display Help IDE=type: Specify the IDE being used LANG=language: Specify the Language for Messages MAC=number: Limit MAC Hardware Block Usage MEMMAP=mapfile: Display memory map MSGFORMAT=format: Set Advisory Message Format MSGDISABLE=messagelist: Disable Warning Messages NODEL: Do not Remove Temporary Files NOEXEC: Don’t execute compiler OBJDIR=path: Specify Directory for Intermediate Files OPT: Invoke Compiler Optimizations OUTDIR=path: Specify Directory for Output Files OUTPUT=type: Specify Output File Type PASS1: Compile to p-code Intermediate File PRE: Produce Preprocessed Source Code PROTO: Generate Prototypes RAM=lo-hi,: Specify additional RAM ranges REENTRANT: Force functions to be re-entrant ROM=lo-hi,|tag: Specify additional ROM ranges RUNTIME=type: Specify Runtime Environment SCANDEP: Scan for dependencies SERIAL=hexcode@address: Store a Value at this Program Memory Address SETOPTION=app,file: Set the command line options for application SETUP=dir: Setup the product STRICT: Strict ANSI Conformance SUMMARY=type: Select memory summary output type TIME: Report time taken for each phase of build process VER: Display the compiler’s version information WARN=level: Set Warning Level WARNFORMAT=format: Set Warning Message Format WDT=period: Specify watchdog timer period C Language Features 3.1 ANSI Standard Issues 3.1.1 Implementation-defined behaviour 3.2 Processor-related Features 3.2.1 Stacks 56 57 57 57 57 58 58 58 58 59 59 59 59 60 60 60 61 62 62 63 63 63 64 64 65 65 65 65 65 66 66 66 69 69 69 69 69 CONTENTS 3.3 3.4 3.5 3.6 3.2.2 Endianism Supported Data Types and Variables 3.3.1 Radix Specifiers and Constants 3.3.2 Bit Data Types and Variables 3.3.3 8-Bit Integer Data Types and Variables 3.3.4 16-Bit Integer Data Types 3.3.5 24-Bit Integer Data Types 3.3.6 32-Bit Integer Data Types and Variables 3.3.7 Floating Point Types and Variables 3.3.8 Structures and Unions 3.3.8.1 Bitfields in Structures 3.3.8.2 Structure and Union Qualifiers 3.3.9 Standard Type Qualifiers 3.3.9.1 Const and Volatile Type Qualifiers 3.3.10 Special Type Qualifiers 3.3.10.1 Persistent Type Qualifier 3.3.10.2 ioport Type Qualifier 3.3.11 Pointer Types 3.3.11.1 Combining Type Qualifiers and Pointers 3.3.11.2 Data Pointers 3.3.11.3 Pointers to Const 3.3.11.4 Pointers to Both Memory Spaces 3.3.11.5 Function Pointers Storage Class and Object Placement 3.4.1 Local Variables 3.4.1.1 Auto Variables 3.4.1.2 Static Variables 3.4.2 Absolute Variables 3.4.3 Objects in the Program Space Functions 3.5.1 Function Qualifiers 3.5.1.1 Interrupt Function Qualifier 3.5.1.2 Reentrant Function Qualifier 3.5.1.3 Fastcall16 Function Qualifier 3.5.2 Function Argument Passing 3.5.2.1 Reentrant Function Parameters 3.5.2.2 Non-reentrant Function Parameters 3.5.3 Function Return Values Operators CONTENTS 70 70 70 72 73 73 73 74 74 75 75 77 77 78 78 78 79 79 80 81 82 83 84 84 84 84 85 85 86 86 86 86 86 87 87 87 87 88 88 CONTENTS 3.6.1 Integral Promotion 3.6.2 Rotate Operations 3.6.3 Shifts applied to integral types 3.6.4 Division and modulus with integral types 3.7 Psects 3.7.1 Compiler-generated Psects 3.8 Interrupt Handling in C 3.8.1 Interrupt Functions 3.8.1.1 Context Saving on Interrupts 3.8.1.2 Context Restoration 3.8.2 Enabling Interrupts 3.9 Mixing C and assembly code 3.9.1 External Assembly Language Functions 3.9.2 #asm, #endasm and asm() 3.9.3 Accessing C objects from within Assembly Code 3.9.3.1 Equivalent Assembly Symbols 3.9.3.2 Accessing register names from assembler 3.9.4 Interaction between Assembly and C Code 3.9.4.1 Absolute Psects 3.9.4.2 Undefined Symbols 3.10 Preprocessing 3.10.1 C Comments 3.10.2 Preprocessor Directives 3.10.3 Predefined Macros 3.10.4 Pragma Directives 3.10.4.1 The #pragma fastcall16 Directive 3.10.4.2 The #pragma inline Directive 3.10.4.3 The #pragma ioport Directive 3.10.4.4 The #pragma jis and nojis Directives 3.10.4.5 The #pragma pack Directive 3.10.4.6 The #pragma printf_check Directive 3.10.4.7 The #pragma regsused Directive 3.10.4.8 The #pragma switch Directive 3.11 Linking Programs 3.11.1 Replacing Library Modules 3.11.2 Linker-Defined Symbols 3.12 Standard I/O Functions and Serial I/O CONTENTS 88 90 90 91 91 91 93 93 93 94 94 94 94 98 99 99 100 101 101 102 103 103 104 104 104 104 104 104 107 107 108 108 109 109 110 111 111 CONTENTS Macro Assembler 4.1 Assembler Usage 4.2 Assembler Options 4.3 HI-TECH C Assembly Language 4.3.1 Statement Formats 4.3.2 Characters 4.3.2.1 Delimiters 4.3.2.2 Special Characters 4.3.3 Comments 4.3.4 Constants 4.3.4.1 Numeric Constants 4.3.4.2 Character Constants and Strings 4.3.5 Identifiers 4.3.5.1 Significance of Identifiers 4.3.5.2 Assembler-Generated Identifiers 4.3.5.3 Location Counter 4.3.5.4 Register Symbols 4.3.5.5 Symbolic Labels 4.3.6 Expressions 4.3.7 Program Sections 4.3.8 Assembler Directives 4.3.8.1 GLOBAL 4.3.8.2 EXPORT 4.3.8.3 END 4.3.8.4 PSECT 4.3.8.5 AREA 4.3.8.6 ORG 4.3.8.7 EQU 4.3.8.8 SET 4.3.8.9 DB 4.3.8.10 DW 4.3.8.11 DDW 4.3.8.12 DWL 4.3.8.13 DS 4.3.8.14 DSU 4.3.8.15 ASCIZ 4.3.8.16 BLK 4.3.8.17 BLKW 4.3.8.18 IF, ELSIF, ELSE and ENDIF CONTENTS 113 113 114 116 116 117 117 117 117 118 118 118 119 119 119 120 120 120 121 122 124 124 124 126 126 128 128 129 129 129 130 130 130 130 131 131 131 131 132 CONTENTS 4.4 CONTENTS 4.3.8.19 MACRO and ENDM 4.3.8.20 LOCAL 4.3.8.21 ALIGN 4.3.8.22 REPT 4.3.8.23 IRP and IRPC 4.3.8.24 INCLUDE 4.3.8.25 PROCESSOR 4.3.8.26 SIGNAT 4.3.9 Assembler Controls 4.3.9.1 COND 4.3.9.2 EXPAND 4.3.9.3 INCLUDE 4.3.9.4 LIST 4.3.9.5 NOCOND 4.3.9.6 NOEXPAND 4.3.9.7 NOLIST 4.3.9.8 NOXREF 4.3.9.9 PAGE 4.3.9.10 SPACE 4.3.9.11 SUBTITLE 4.3.9.12 TITLE 4.3.9.13 XREF Assembler List Files 4.4.1 Generation 4.4.2 Contents Linker and Utilities 5.1 Introduction 5.2 Relocation and Psects 5.3 Program Sections 5.4 Local Psects 5.5 Global Symbols 5.6 Link and load addresses 5.7 Operation 5.7.1 Numbers in linker options 5.7.2 -Aclass=low-high, 5.7.3 -Cx 5.7.4 -Cpsect=class 5.7.5 -Dclass=delta 132 134 134 135 135 136 136 136 137 137 137 138 138 138 138 139 139 139 139 139 139 139 140 140 140 143 143 143 144 144 144 145 145 146 147 147 148 148 CONTENTS 5.7.6 -Dsymfile 5.7.7 -Eerrfile 5.7.8 -F 5.7.9 -Gspec 5.7.10 -Hsymfile 5.7.11 -H+symfile 5.7.12 -Jerrcount 5.7.13 -K 5.7.14 -I 5.7.15 -L 5.7.16 -LM 5.7.17 -Mmapfile 5.7.18 -N, -Ns and-Nc 5.7.19 -Ooutfile 5.7.20 -Pspec 5.7.21 -Qprocessor 5.7.22 -S 5.7.23 -Sclass=limit[, bound] 5.7.24 -Usymbol 5.7.25 -Vavmap 5.7.26 -Wnum 5.7.27 -X 5.7.28 -Z 5.8 Invoking the Linker 5.9 Compiled Stack Operation 5.9.1 Parameters involving Function Calls 5.10 Map Files 5.10.1 Generation 5.10.2 Contents 5.10.2.1 General Information 5.10.2.2 Call Graph Information 5.10.2.3 Psect Information listed by Module 5.10.2.4 Psect Information listed by Class 5.10.2.5 Segment Listing 5.10.2.6 Unused Address Ranges 5.10.2.7 Symbol Table 5.11 Librarian 5.11.1 The Library Format 5.11.2 Using the Librarian 10 CONTENTS 148 148 148 148 149 149 149 150 150 150 150 150 150 150 151 152 152 152 153 153 153 153 153 154 154 155 157 157 157 158 159 165 167 167 167 168 169 169 169 INDEX assembly statements format of, 116 assert function, 197 atan function, 198 atan2 function, 199 atof function, 200 atoi function, 201 atol function, 202 auto variables, 84 Avocet symbol file, 153 base specifier, see rdix specifier118 bases C source, 70 biased exponent, 75 big endian format, 183 binary constants assembly, 118 C, 70 bit PSECT flag, 127 bit types in assembly, 127 bit-fields, 75 initializing, 76 unamed, 76 bitbss psect, 92 bitwise complement operator, 89 BLK directive, 131 BLKW directive, 131 blocks, see pects122 bootloader, 63, 179, 186 bootloaders, 184 bsearch function, 203 bss psect, 34, 64, 85, 92, 144 clearing, 144 byte addresses, 182 C standard libraries, 31, 32 446 INDEX call graph, 159 callgraph critical path, 162 ceil function, 205 cgets function, 206 char types, 54, 73 char variables, 54 character constants, 71 assembly, 118 checksum endianism, 54, 183 checksum specifications, 172 checksums, 54, 179, 183 algorithms, 54, 183 endianism, 54, 183 chipinfo files, 115 class PSECT flag, 127 classes, 148 address ranges, 147 boundary argument, 152 upper address limit, 152 clearing of variables, 34 clib suboption, 31 COD file, 60 command files, 25 command line driver, 23 command lines HLINK, long command lines, 154 long, 25, 171 verbose option, 53 compiled stack, 159 compiler options, 44 compiler errors format, 40 compiler generated psects, 91 compiler-generate input files, 30 compiling to assembly file, 52 to object file, 46 INDEX PSECT flag, 127 COND assembler control, 137 conditional assembly, 132 console I/O functions, 111 const psect, 92 const qualifier, 78 constants assembly, 118 C specifiers, 70 character, 71 string, see sring literals71 context retrieval, 94 context saving, 93 in-line assembly, 108 copyright notice, 52 cos function, 208 cosh function, 209 CPSOC –ERRFORMAT=format, 56 –MSGFORMAT=format, 56 –WARNFORMAT=format, 56 options, 44 version number, 65 CPSOC, see driver CPSOC options –ASMLIST, 53 –CHAR=type, 54 –CHECKSUM, 54 –CHIPINFO, 55 –CR=file, 55 –DOUBLE, 55 –GETOPTION=app,file, 56 –HELP, 57 –IDE=type, 57 –LANG=language, 57 –MEMMAP, 58 –MSGDISABLE=messagelist, 58 –MSGFORMAT=format, 58 –NODEL, 58 INDEX –NOEXEC, 59 –OBJDIR=path, 59 –OPT=type, 59 –OUTDIR=path, 59 –OUTPUT=type, 60 –PRE, 60 –PROTO, 61 –RAM=lo-hi, 62 –ROM=lo-hi, 63 –RUNTIME=type, 63 –SCANDEP, 63 –SERIAL, 64 –SETOPTION=app,file, 64 –SETUP=dir, 65 –STRICT, 65 –SUMMARY=type, 65 –TIME, 65 –VER, 65 –WARN=level, 66 –WARNFORMAT, 66 –WDT, 66 -C, 46 -D, 47 -Efile, 47 -G, 48 -I, 48 -L, 49 -M, 51 -Nsize, 51 -O, 51 -P, 52 -Q, 52 -S, 52 -U, 52 -V, 53 -X, 53 CPSOC options –CHAR=type, 73 cputs function, 210 447 INDEX creating libraries, 170 creating new, 91 CREF, 115 CREF application, 174 CREF option -Fprefix, 174 -Hheading, 174 -Llen, 175 -Ooutfile, 175 -Pwidth, 175 -Sstoplist, 175 -Xprefix, 175 CREF options, 174 critical path, 162 cromwell application, 176 cromwell option -B, 179 -C, 177 -D, 177 -E, 178 -F, 178 -Ikey, 178 -L, 178 -M, 179 -N, 177 -Okey, 178 -P, 176 -V, 179 cromwell options, 176 cross reference disabling, 139 generating, 174 list utility, 174 cross reference file, 115 generation, 115 cross reference listings, 55 excluding header symbols, 174 excluding symbols, 175 448 INDEX headers, 174 output name, 175 page length, 175 page width, 175 cross referencing enabling, 139 ctime function, 211 data psect, 64, 92, 144 copying, 145 data psects, 33 data types, 70 16-bit integer, 73 24-bit integer, 73 8-bit integer, 73 assembly, 119 char, 73 floating point, 74 int, 73 long short, 73 short, 73 short long, 73 DB directive, 129 DDW directive, 130 debug information, 37, 38, 48 assembler, 116 optimizers and, 115 default psect, 124 delta PSECT flag, 127 delta psect flag, 148 dependencies, 63 dependency checking, 28 device selection, 54, 55 directives asm, C, 98 assembler, 124 EQU, 120 div function, 212 divide by zero INDEX result of, 91 doprnt.c source file, 35 doprnt.pre, 36 double type, 55 driver command file, 25 command format, 24 input files, 24 long command lines, 25 options, 24 single step compilation, 27 driver option –ERRFORMAT=format, 56 –ERRORS=number, 56 –LANG=language, 57 –MSGFORMAT=format, 56 –NODEL, 27 –OUTPUT=type, 60 –PASS1, 26, 28, 29 –PRE, 29 –RUNTIME, 31 –RUNTIME=type, 32–34 –WARN=level, 66 –WARNFORMAT=format, 56 -C, 28 -Efile, 47 -G, 37, 48 -I, 48 -L, 49 -M, 51 -O, 37 -S, 52 driver options –WARNFORMAT=format, 66 DS directive, 130 DSU directive, 131 DW directive, 130 DWL directive, 130 INDEX ellipsis symbol, 87 ELSE directive, 132 ELSIF directive, 132 embedding serial numbers, 188 END directive, 35, 126 end_init psect, 92 endianism, 70 ENDIF directive, 132 ENDM directive, 132 enhanced symbol files, 149 environment variable HTC_ERR_FORMAT, 40 HTC_MSG_FORMAT, 40 HTC_WARN_FORMAT, 40 EQU directive, 100, 120, 129 equ directive, 116 equating assembly symbols, 129 error files creating, 148 error messages, 47 formatting, 40 LIBR, 172 eval_poly function, 213 exceptions, 93 exit function, 214 exp function, 215 EXPAND assembler control, 137 exponent, 74 expressions assembly, 121 relocatable, 122 extern keyword, 94 fabs function, 216 fast doubles, 55 fastcall16, 87 fastcall16 pragma directive, 104 file extensions, 24 file formats 449 INDEX assembler listing, 53 Avocet symbol, 153 command, 171 creating with cromwell, 176 cross reference, 115, 174 cross reference listings, 55 dependency, 63 DOS executable, 150 enhanced symbol, 149 library, 169, 171 link, 154 object, 46, 150, 171 preprocessor, 60 prototype, 61 specifying, 60 symbol, 149 symbol files, 37, 38 TOS executable, 150 files intermediate, 58–60 output, 59 temporary, 58, 59 fill memory, 179 filling unused memory, 56, 183 flash_readBlock, 217 flash_writeBlock, 218 floating point data types, 74 biased exponent, 75 exponent, 75 format, 74 mantissa, 74 floating suffix, 71 floor function, 220 fmod function, 219 fnauto psect, 92 frexp function, 221 ftoa function, 222 function return addresses, 69 450 INDEX return values, 88 function prototypes, 136 ellipsis, 87 function return values, 88 function signatures, 136 functions argument passing, 87 getch, 111 interrupt, 93 interrupt qualifier, 93 kbhit, 111 putch, 111 re-entrant, 62 written in assembler, 94 getch function, 111, 223 getchar function, 224 getche function, 223 gets function, 225 GLOBAL directive, 124 global optimization, 59 global PSECT flag, 127 global symbols, 144 gmtime function, 226 hardware initialization, 34 hardware stack, 69 header files problems in, 65 HEX file format, 186 HEX file map, 187 hex files address alignment, 56, 184 address map, 179 calculating check sums, 179 converting to other Intel formats, 179 data record, 182 detecting instruction sequences, 179 INDEX embedding serial numbers, 180 extended address record, 186 filling unused memory, 56, 179 find and replacing instructions, 179 merging multiple, 179 multiple, 148 record length, 56, 179, 184, 186 hexadecimal constants assembly, 118 hexmate application, 27, 179 hexmate option +prefix, 182 -CK, 183 -FILL, 183, 186 -FIND, 184 -FIND ,DELETE, 185 -FIND ,REPLACE, 185 -FORMAT, 186 -HELP, 187 -LOGFILE, 187 -MASK, 187 -O, 187 -SERIAL, 64, 188 -SIZE, 188 -STRING, 188 -STRPACK, 189 -addressing, 182 -break, 182 file specifications, 180 hexmate options, 180 HI-TIDE, 57 HTC_ERR_FORMAT, 40 HTC_MSG_FORMAT, 40 HTC_WARN_FORMAT, 40 I/O console I/O functions, 111 serial, 111 STDIO, 111 INDEX idata psect, 33 identifier length, 51 identifiers assembly, 119 IEEE floating point format, 74 IF directive, 132 Implementation-defined behaviour division and modulus, 91 shifts, 90 implementation-defined behaviour, 69 INCLUDE assembler control, 138 INCLUDE directive, 136 include files assembly, 138 incremental builds, 28 INHX32, 179, 186 INHX8M, 179, 186 init psect, 92 initialization of variables, 33 inline pragma directive, 104 input files, 24 int data types, 73 integer suffix long, 71 unsigned, 71 integral constants, 71 integral promotion, 89 Intermediate files, 60 intermediate files, 24, 28, 59 interrupt, 86 interrupt functions, 93 context retrieval, 94 context saving, 93, 108 interrupt keyword, 93 interrupt qualifier, 93 interrupt service routines, 93 interrupts handling in C, 93 intrtext psect, 92 451 INDEX ioport pragma directive, 104 IRP directive, 135 IRPC directive, 135 isalnum function, 228 isalpha function, 228 isatty function, 230 isdigit function, 228 islower function, 228 itoa function, 231 Japanese character handling, 107 JIS character handling, 107 jis pragma directive, 107 kbhit function, 111 keyword auto, 84 interrupt, 93 persistent, 34, 78 keywords disabling non-ANSI, 65 l.obj output file, 27 label field, 116 labels assembly, 120 global, 120 local, 120 re-usable local, 120 local, 134 labs function, 232 language support, 39 ldexp function, 233 ldiv function, 234 LIBR, 169 command line arguments, 169 error messages, 172 listing format, 171 long command lines, 171 module order, 172 452 INDEX librarian, 169 command files, 171 command line arguments, 169, 171 error messages, 172 listing format, 171 long command lines, 171 module order, 172 libraries adding files to, 170 creating, 170 deleting files from, 170 excluding, 64 format of, 169 linking, 153 listing modules in, 170 module order, 172 scanning additional, 49 used in executable, 150 library difference between object file, 169 manager, 169 library function abs, 192 acos, 193 asctime, 194 asin, 196 assert, 197 atan, 198 atan2, 199 atof, 200 atoi, 201 atol, 202 bsearch, 203 ceil, 205 cgets, 206 cos, 208 cosh, 209 cputs, 210 ctime, 211 INDEX div, 212 eval_poly, 213 exit, 214 exp, 215 fabs, 216 flash_readBlock, 217 flash_writeBlock, 218 floor, 220 fmod, 219 frexp, 221 ftoa, 222 getch, 223 getchar, 224 getche, 223 gets, 225 gmtime, 226 isalnum, 228 isalpha, 228 isatty, 230 isdigit, 228 islower, 228 itoa, 231 labs, 232 ldexp, 233 ldiv, 234 localtime, 235 log, 237 log10, 237 longjmp, 238 ltoa, 240 memchr, 241 memcmp, 243 memcpy, 245 memset, 246 mktime, 247 modf, 248 persist_check, 249 persist_validate, 249 pow, 251 INDEX printf, 35, 252 putch, 255 putchar, 256 puts, 258 qsort, 259 rand, 261 round, 263 scanf, 264 setjmp, 266 sin, 268 sinh, 209 sprintf, 269 sqrt, 270 srand, 271 sscanf, 272 strcat, 273 strchr, 274 strcmp, 276 strcpy, 278 strcspn, 279 strichr, 274 stricmp, 276 stristr, 290 strlen, 280 strncat, 281 strncmp, 283 strncpy, 285 strnicmp, 283 strpbrk, 287 strrchr, 288 strrichr, 288 strspn, 289 strstr, 290 strtod, 291 strtok, 295 strtol, 293 tan, 297 tanh, 209 time, 298 453 INDEX toascii, 300 tolower, 300 toupper, 300 trunc, 301 ungetc, 302, 303 ungetch, 304 utoa, 305 va_arg, 306 va_end, 306 va_start, 306 vprintf, 252 vscanf, 264 vsprintf, 269 vsscanf, 272 xtoi, 308 limit PSECT flag, 127 limiting number of error messages, 56 link addresses, 145, 151 linker, 143 command files, 154 command line arguments, 145, 154 invoking, 154 long command lines, 154 passes, 169 symbols handled, 144 linker defined symbols, 111 linker errors aborting, 149 undefined symbols, 150 linker option -Aclass=low-high, 147, 152 -Cpsect=class, 148 -Dsymfile, 148 -Eerrfile, 148 -F, 148 -Gspec, 148 -H+symfile, 149 -Hsymfile, 149 -I, 150 454 INDEX -Jerrcount, 149 -K, 150 -L, 150 -LM, 150 -Mmapfile, 150 -N, 150 -Nc, 150 -Ns, 150 -Ooutfile, 150 -Pspec, 151 -Qprocessor, 152 -Sclass=limit[,bound], 152 -Usymbol, 153 -Vavmap, 153 -Wnum, 153 -X, 153 -Z, 153 linker options, 145 adjusting use driver, 49 numbers in, 146 linking programs, 109 LIST assembler control, 138 list files, see asembler listings115 assembler, 53 little endian format, 73, 74, 183 load addresses, 145, 151 local assembly labels, 120 LOCAL directive, 119, 134 local PSECT flag, 127 local psects, 144 local symbols, 53 suppressing, 116, 153 local variables, 84 auto, 84 static, 85 localtime function, 235 location counter, 120, 128 log function, 237 LOG10 function, 237 INDEX long data types, 74 long integer suffix, 71 long short data types, 73 longjmp function, 238 ltoa function, 240 M8C assembly language functions, 94 M8C MCU assembly language, 116 MACRO directive, 132 macro directive, 116 macros disabling in listing, 138 expanding in listings, 115, 137 nul operator, 133 predefined, 104 repeat with argument, 135 undefining, 52 unnamed, 135 main function, 29, 32 maintext psect, 92 mantissa, 74 map files, 150 call graph, 159 generating, 51 processor selection, 152 segments, 157 symbol tables in, 150 width of, 153 maximum number of errors, 56 MDF, 38 memchr function, 241 memcmp function, 243 memcpy function, 245 memory reserving, 62, 63 specifying, 62, 63 specifying ranges, 147 unused, 56, 150 INDEX memory pages, 128 memory summary, 65 memset function, 246 merging hex files, 182 message language, 39 message description files, 38 messages disabling, 58 warning, 58 Microchip COF file, 60 mktime function, 247 modf function, 248 module, 24 modules in library, 169 list format, 171 order in library, 172 used in executable, 150 MPLAB, 57 build options, 49 multi-character constants assembly, 119 multiple hex files, 148 NOCOND assembler control, 138 NOEXPAND assembler control, 138 nojis pragma directive, 107 NOLIST assembler control, 139 non-volatile memory, 92 non-volatile RAM, 78 NOXREF assembler control, 139 numbers C source, 70 in linker options, 146 nvbit psect, 92 nvram psect, 78, 92 object code, version number, 150 455 INDEX object files, 46 absolute, 150 relocatable, 143 specifying name of, 116 suppressing local symbols, 116 symbol only, 148 OBJTOHEX, 172 command line arguments, 172 objtohex application, 27 Optimizations assembler, 59 code generator, 59 debugging, 59 global, 59 optimizations assembler, see asembler optimizer115 options ASPSOC, see APSOC options114 ORG directive, 128 output specifying name of, 51 output directory, 59 output file, 51 output file formats, 150 American Automation HEX, 60 Binary, 60 Bytecraft COD, 60 COFF, 60 ELF, 60 Intel HEX, 60 library, 60 Microchip COFF, 60 Motorola S19 HEX, 60 specifying, 60, 172 Tektronic, 60 UBROF, 60 output files, 59 l.obj, 27 names of, 25 456 INDEX overlaid memory areas, 150 overlaid psects, 127 ovr PSECT flag, 127 ovrld PSECT flag, 127 p-code files, 24 pack pragma directive, 107 PAGE assembler control, 139 parameter passing, 87, 88, 94 persist_check function, 249 persist_validate function, 249 persistent keyword, 78 persistent qualifier, 34, 78 persistent variables, 92 PICC18 options –CHIP=processor, 54 –FILL, 56 PICC18 output formats American Automation Hex, 37 Binary, 37 Bytecraft, 37 Intel Hex, 37 Motorola Hex, 37 Tektronix Hex, 37 UBROF, 37 pointer qualifiers, 79, 80 pointers, 79 16bit, 79 32 bit, 79 combining with type modifiers, 80 to functions, 79 pow function, 251 powerup psect, 92 powerup routine, 32, 34 powerup.as, 34 pragma fastcall16, 87 pragma directives, 104 INDEX predefined symbols preprocessor, 104 preprocessing, 52 assembler files, 52 preprocessor macros, 47 path, 48 preprocessor directives, 104 #asm, 98 #endasm, 98 in assembly files, 117 preprocessor symbols predefined, 104 printf format checking, 108 printf function, 30, 252 printf_check pragma directive, 108 processor selection, 54, 55, 136, 152 program entry point, 35 program sections, 122 project name, 25 psect bitbss, 92 bss, 34, 64, 92, 144 const, 92 data, 64, 92, 144 end_init, 92 fnauto, 92 idata, 33 init, 92 intrtext, 92 maintext, 92 nvbit, 92 nvram, 78, 92 powerup, 92 rdata, 33 strings, 92 text, 92 vectors, 92 INDEX PSECT directive, 122, 126 PSECT directive flag limit, 153 PSECT flags abs, 126 bit, 127 class, 127 con, 127 delta, 127 global, 127 limit, 127 local, 127 ovr, 127 ovrld, 127 pure, 127 rel, 127 reloc, 127 size, 127 space, 128 with, 128 psect flags, 126 psect pragma directive, 50 psects, 91, 122, 144 absolute, 126, 127 aligning within, 134 alignment of, 127 basic kinds, 144 class, 147, 148, 152 compiler generated, 91 default, 124 delta value of, 148 differentiating ROM and RAM, 128 linking, 143 listing, 65 local, 144 maximum size of, 127 page boundaries and, 128 specifying address ranges, 152 specifying addresses, 147, 151 457 INDEX pseudo-ops assembler, 124 pure PSECT flag, 127 putch function, 111, 255 putchar function, 256 puts function, 258 qsort function, 259 qualifier interrupt, 93 persistent, 34, 78 qualifiers, 77 and auto variables, 84 auto, 84 const, 78 pointer, 79 special, 78 volatile, 78 quiet mode, 52 INDEX relocation, 143 relocation information preserving, 150 REPT directive, 135 reserving memory, 62, 63 reset code executed after, 34 return values, 88 round function, 263 runtime environment, 63 runtime startup and watchdog timer, 66 variable initialization, 33 runtime startup code, 32 runtime startup module, 30, 64 scale value, 127 scanf function, 264 search path header files, 48 segment selector, 148 radix specifiers segments, see aso psects122, 148, 157 assembly, 118 serial I/O, 111 C source, 70 serial numbers, 64, 188 rand function, 261 SET directive, 129 rdata psect, 33 set directive, 116 re-entrant functions, 62 setjmp function, 266 re-usable local assembly labels, 120 SFRs read-only variables, 78 using in assembler code, 100 redirecting errors, 47 shift operations reference, 146, 157 result of, 90 registers special function, see secial function regis- short long data types, 73 ters120 sign extension when shifting, 90 regsused pragma directive, 108 SIGNAT directive, 136 rel PSECT flag, 127 signatures, 136 RELOC, 148, 151 sin function, 268 reloc PSECT flag, 127 single step compilation, 27 relocatable sinh function, 209 object files, 143 size of doubles, 55 458 INDEX size PSECT flag, 127 skipping applications, 64 source file, 24 SPACE assembler control, 139 space PSECT flag, 128 special characters, 117 special function registers in assembly code, 120 predefined, 100 special type qualifiers, 78 sports cars, 119 sprintf function, 269 sqrt function, 270 srand function, 271 sscanf function, 272 stack, 69 stack pointer, 64, 69 standard library files, 31, 32 standard type qualifiers, 77 start label, 35 startup module, 64 clearing bss, 144 data copying, 145 startup.as, 32 static variables, 85 STDIO, 111 storage class, 84 strcat function, 273 strchr function, 274 strcmp function, 276 strcpy function, 278 strcspn function, 279 strichr function, 274 stricmp function, 276 string literals, 71, 188 concatenation, 71 String packing, 189 strings assembly, 119 INDEX storage location, 71, 188 type of, 71 strings psect, 92 stristr function, 290 strlen function, 280 strncat function, 281 strncmp function, 283 strncpy function, 285 strnicmp function, 283 strpbrk function, 287 strrchr function, 288 strrichr function, 288 strspn function, 289 strstr function, 290 strtod function, 291 strtok function, 295 strtol function, 293 structures alignment,padding, 107 bit-fields, 75 qualifiers, 77 SUBTITLE assembler control, 139 SUMMARY option class, 66 file, 66 hex, 66 mem, 66 psect, 66 switch pragma directive, 109 symbol files, 37, 38, 48 Avocet format, 153 enhanced, 149 generating, 149 local symbols in, 153 old style, 148 removing local symbols from, 53 removing symbols from, 152 source level, 48 symbol tables, 150, 153 459 INDEX sorting, 150 symbols assembler-generated, 119 global, 144, 170 linker defined, 111 undefined, 153 tan function, 297 function, 209 temporary files, 59 text psect, 92 time function, 298 timer watchdog, 66 TITLE assembler control, 139 toascii function, 300 tolower function, 300 toupper function, 300 translation unit, 25 trunc function, 301 type modifiers combining with pointers, 80 type qualifiers, 77 typographic conventions, 21 unamed structure members, 76 ungetc function, 302, 303 ungetch function, 304 unnamed psect, 124 unsigned integer suffix, 71 unused memory filling, 179 utilities, 143 utoa function, 305 va_arg function, 306 va_end function, 306 va_start function, 306 variable argument list, 87 variable initialization, 33 460 INDEX variables absolute, 85 accessing from assembler, 99, 100 auto, 84 char types, 73 floating point types, 74 int types, 73 local, 84 persistent, 92 static, 85 unique length of, 51 vectors psect, 92 verbose, 53 version number, 65 volatile qualifier, 78 vprintf function, 252 vscanf function, 264 vsprintf function, 269 vsscanf function, 272 warning level, 66 setting, 153 warning message format, 66 warnings level displayed, 66 suppressing, 153 watchdog timer, 66 with PSECT flag, 128 word addresses, 182 word boundaries, 127 XREF assembler control, 139 xtoi function, 308 ... follows: 47 CPSOC Driver Option Descriptions CPSOC Command-line Driver CPSOC CHIP=CY 8C2 9466 -Eproject.err -O PASS1 main .c CPSOC CHIP=CY 8C2 9466 -E+project.err -O PASS1 part1 .c CPSOC CHIP=CY 8C2 9466... to be compiled using a multi-step compilation The following could be used CPSOC CPSOC CPSOC CPSOC chip=CY 8C2 9466 chip=CY 8C2 9466 chip=CY 8C2 9466 chip=CY 8C2 9466 pass1 main .c pass1 io .c -c mdef.as... assembler controls LIST control options Devices supported by HI-TECH C Devices supported by HI-TECH C Devices supported by HI-TECH C Devices supported by HI-TECH C Devices