Transcription of MPLAB XC8 C Compiler User’s Guide for PIC
1 MPLAB XC8 C CompilerUser s Guide for PIC MPLAB XC8 C Compiler User s Guide for PIC MCUN otice to CustomersAll documentation becomes dated and this manual is no exception. Microchip tools and documentation are constantlyevolving to meet customer needs, so some actual dialogs and/or tool descriptions can differ from those in thisdocument. Please refer to our web site ( ) to obtain the latest documentation are identified with a DS number. This number is located on the bottom of each page, in front of the pagenumber. The numbering convention for the DS number is DSXXXXXA, where XXXXX is the document numberand A is the revision level of the the most up-to-date information on development tools, see the MPLAB IDE online help. Select the Help menu,and then Topics to open a list of available online help files. 2020 Microchip Technology Inc. User Guide50002737C-page 1 Table of ContentsNotice to Used in This Systems Customer Change Notification and Development and Activating the the Source My Application To Do What I the Compilation Code That Does Not The Compilation X IDE Language Standard Data Types and Allocation and and , Runtime Startup and C and Assembly 139 MPLAB XC8 C Compiler User s Guide .
2 2020 Microchip Technology Inc. User Guide50002737C-page XC8 Assembly List and < > < > Character < > < > Floating-Point < > Integer Format < > Alternate < > Implementation-Defined < > Mathematical < > Non-Local < > Variable Argument < > Boolean Types and < > Common < > Integer < > Input and < > Utility < > String < > Date and Time < > Device-specific and Warning 0 Thru 500 Thru 1000 Thru 1500 Thru 2000 Thru MPLAB XC8 C Compiler User s Guide .. 2020 Microchip Technology Inc. User Guide50002737C-page and , Unions, Enumerations, and Revision Microchip Change Notification 582 Microchip Devices Code Protection 583 Quality Management 583 Worldwide Sales and MPLAB XC8 C Compiler User s Guide .. 2020 Microchip Technology Inc. User Guide50002737C-page 41. Conventions Used in This GuideThe following conventions may appear in this documentation:Table 1-1.
3 Documentation ConventionsDescriptionRepresentsExamples Arial font:Italic charactersReferenced booksMPLAB IDE User s GuideEmphasized the only capsA windowthe Output windowA dialogthe Settings dialogA menu selectionselect Enable ProgrammerQuotesA field name in a window or dialog Save project before build Underlined, italic text with rightangle bracketA menu pathFile>SaveBold charactersA dialog buttonClick OKA tabClick the Power tabN RnnnnA number in verilog format, whereN is the total number of digits, R isthe radix and n is a b0010, 2 hF1 Text in angle brackets < >A key on the keyboardPress <Enter>, <F1>Courier New font:Plain Courier NewSample source code#define pathsc:\mcc18\hKeywords_asm, _endasm, staticCommand-line options-Opa+, -Opa-Bit values0, 1 Constants0xFF, A Italic Courier NewA variable , where file can be any validfilenameSquare brackets [ ]Optional argumentsmcc18 [options] file [options]Curly brackets and pipe character: { | }Choice of mutually exclusivearguments; an OR selectionerrorlevel {0|1} repeated textvar_name [, ]Represents code supplied by uservoid main (void){.}
4 } MPLAB XC8 C Compiler User s Guide ..Preface 2020 Microchip Technology Inc. User Guide50002737C-page Recommended ReadingThis user s Guide describes the use and features of the MPLAB XC8 C Compiler when building for PIC targets andusing the ISO/IEC 9899:1999 Standard (C99) for programming languages. The following Microchip documents areavailable and recommended as supplemental reference XC8 C Compiler Legacy User s GuideThis version of the Compiler 's user's Guide is for legacy projects that use the old xc8 command line driver or theISO/IEC 9899:1999 Standard (C99) for programming languages. When operating in this mode, the Compiler uses adifferent front end with different specifications and XC8 C Compiler User s Guide for AVR MCUThis version of the Compiler 's user's Guide is for projects that target 8-bit AVR XC8 C Compiler Release Notes for PIC MCUFor the latest information on using MPLAB XC8 C Compiler , read MPLAB XC8 C Compiler Release Notes (anHTML file) in the Docs subdirectory of the Compiler s installation directory.
5 The release notes contain updateinformation and known issues that cannot be included in this user s Tools Release NotesFor the latest information on using other development tools, refer to the tool-specific Readme files in the docssubdirectory of the MPLAB X IDE installation Development Systems Customer Change Notification ServiceMicrochip s customer notification service helps keep customers current on Microchip products. Subscribers willreceive e-mail notification whenever there are changes, updates, revisions or errata that are related to a specifiedproduct family or development tool of register, access the Microchip web site at , click on Customer Change Notification andfollow the registration Development Systems product group categories are:CompilersThe latest information on Microchip C compilers, assemblers, linkers and other languagetools. These include all MPLAB C compilers; all MPLAB assemblers (including MPASM assembler); all MPLAB linkers (including MPLINK object linker); and all MPLAB librarians(including MPLIB object librarian).
6 EmulatorsThe latest information on Microchip in-circuit emulators. This includes the MPLAB REAL ICE and MPLAB ICE 2000 in-circuit latest information on the Microchip in-circuit debuggers. This includes MPLAB ICD 3 in-circuit debuggers and PICkitTM 3 debug IDEThe latest information on Microchip MPLAB IDE, the Windows Integrated DevelopmentEnvironment for development systems tools. This list is focused on the MPLAB IDE, MPLABIDE Project Manager, MPLAB Editor and MPLAB SIM simulator, as well as general editing anddebugging latest information on Microchip programmers. These include production programmerssuch as MPLAB REAL ICE in-circuit emulator, MPLAB ICD 3 in-circuit debugger and MPLABPM3 device programmers. Also included are non-production development programmers suchas PICSTART Plus and PICkit 2 and 3. MPLAB XC8 C Compiler User s Guide ..Preface 2020 Microchip Technology Inc. User Guide50002737C-page 62. Compiler OverviewThe MPLAB XC8 C Compiler is a free-standing, optimizing ISO C99 cross Compiler for the C programming Compiler supports all 8-bit PIC and AVR microcontrollers; however, this document describes the use of thexc8-cc driver for programs that target only Microchip PIC devices, and additionally, that programs are built againstthe C99 Standard.
7 See the MPLAB XC8 C Compiler User s Guide for AVR MCU (DS50002750), for information onusing this Compiler when targeting Microchip AVR devices. If you are using the C90 Standard or the legacy compilerdriver (xc8), see the MPLAB XC8 C Compiler User s Guide (DS50002053) : Features described as being part of MPLAB XC8 in this document assume that you are using a Microchip PICdevice and are building for the C99 C standard. These features may differ if you choose to instead compile for aMicrochip AVR device or for the C90 compiling for the C99 standard, this Compiler utilizes the Clang Compiler front end. The older CPP/P1 front endis used when building for C90 Device DescriptionThis Guide describes the MPLAB XC8 C Compiler 's support for all 8-bit Microchip PIC devices with baseline, mid-range, enhanced mid-range and PIC18 cores. The following descriptions indicate the distinctions within those devicecores:The baseline core uses a 12-bit-wide instruction set and is available in PIC10, PIC12 and PIC16 part enhanced baseline core also uses a 12-bit instruction set, but this set includes additional instructions.
8 Some ofthe enhanced baseline chips support interrupts and the additional instructions used by interrupts. These devices areavailable in PIC12 and PIC16 part mid-range core uses a 14-bit-wide instruction set that includes more instructions than the baseline core. It haslarger data memory banks and program memory pages, as well. It is available in PIC12, PIC14 and PIC16 Enhanced mid-range core also uses a 14-bit-wide instruction set but incorporates additional instructions andfeatures. There are both PIC12 and PIC16 part numbers that are based on the Enhanced mid-range PIC18 core instruction set is 16 bits wide and features additional instructions and an expanded register core devices have part numbers that begin with Compiler takes advantage of the target device s instruction set, addressing modes, memory, and registerswhenever Print-devices for information on finding the full list of devices that are supported by the C StandardsThis Compiler is a freestanding implementation that conforms to the ISO/IEC 9899:1990 Standard (referred to as theC90 standard) as well the ISO/IEC 9899:1999 Standard (C99) for programming languages, unless otherwise addition, language extensions customized for 8-bit PIC embedded-control applications are Hosts and LicensesThe MPLAB XC8 C Compiler is available for several popular operating systems.
9 See the Compiler release notes forthose that apply to your Compiler Compiler can be run with or without a license. A license can be purchased and applied at any time, permitting ahigher level of optimization to be employed. Otherwise, the basic Compiler operation, supported devices and availablememory when using an unlicensed Compiler are identical to those when using a licensed Compiler . MPLAB XC8 C Compiler User s Guide .. Compiler Overview 2020 Microchip Technology Inc. User Guide50002737C-page ConventionsThroughout this manual, the term Compiler is used. It can refer to all, or a subset of, the collection of applicationsthat comprise the MPLAB XC8 C Compiler . When it is not important to identify which application performed an action,it will be attributed to the Compiler . In a similar manner, Compiler is often used to refer to the command-line driver; although specifically, the driver forthe MPLAB XC8 C Compiler package is named xc8-cc.
10 The driver and its options are discussed in OptionDescriptions. Accordingly, Compiler options commonly refers to command-line driver a similar fashion, compilation refers to all or a selection of steps involved in generating an executable binaryimage from source Compatible Development ToolsThe Compiler works with many other Microchip tools, including: The MPLAB X IDE ( ) The MPLAB X Simulator The Command-line MDB Simulator see the Microchip Debugger (MDB) User s Guide (DS52102) All Microchip debug tools and programmers ( ) Demonstration boards and Starter kits that support 8-bit devices MPLAB XC8 C Compiler User s Guide .. Compiler Overview 2020 Microchip Technology Inc. User Guide50002737C-page 83. How TosThis section contains help and references for situations that are frequently encountered when building projects forMicrochip 8-bit PIC devices. Click the links at the beginning of each section to assist in finding the topic relevant toyour question.