9/317
Table of Contents
7.8 SUMMARY REMARKS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
8CLANGUAGEANDTHECCOMPILER ....................................221
8.1 CLANGUAGEEXTENSIONSFORMICROCONTROLLERS ...............221
8.2 DESCRIPTION AND INSTALLATION OF THE HICROSS TOOL CHAIN . . . . . . 222
8.3 USINGTHECCOMPILER ..........................................226
8.3.1 Memoryallocation.....................................................226
8.3.1.1 Read-only constants . . ............................................227
8.3.1.2 EEPROMnon-volatilestorage.......................................228
8.3.1.3 PageZerovariables...............................................229
8.3.1.4 Far and near pointers . ............................................229
8.3.2 Initializationofvariablesandconstantvariables..............................230
8.3.3 Inputs and outputs ....................................................230
8.3.3.1 First method: using macros .........................................231
8.3.3.2 Second method: defining variables ...................................231
8.3.4 Interrupthandling .....................................................232
8.3.5 Limitations put on the full implementation of C language .......................232
8.4 USING THE ASSEMBLER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
8.4.1 UsingIn-lineassemblerstatementswithinaCsourcetext .....................233
8.4.1.1 Single-statementassemblerblock....................................233
8.4.1.2 Multiple-statementassemblerblock ..................................234
8.4.2 UsingtheHiwareassembler.............................................235
8.5 USINGTHELINKER...............................................235
8.6 USING THE EPROM BURNER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
8.7 PROJECTDIRECTORYSTRUCTURE ................................239
8.7.1 Configdirectory.......................................................239
8.7.2 Objectdirectory.......................................................241
8.7.3 Sourcesdirectory .....................................................241
8.8 HINTSONCWRITINGSTYLEFORTHEST7 ..........................242
8.8.1 Accessingindividualbitsinregisters ......................................242
8.8.2 Settingconfigurationregisters ...........................................245
8.8.3 Usingmacrostodefineexternaldevices ...................................245
8.8.4 Optimizingresourceusage..............................................246
8.8.4.1 Define a function when a group of statements is repeated several times ......247
8.8.4.2 Useshiftsinsteadofmultiplicationanddivision..........................247
8.8.4.3 Limitthesizeofvariablestotheveryminimum..........................248