
OSMIC Version 4.6 CSoftware C Cross Compiler User’s Guide for Motorola HC12/HCS12 Copyright © COSMIC Software 1995, 2004 All Trademarks are the property of their respective owners Table of Contents Preface Organization of this Manual ....................................................... 1 Chapter 1 Introduction Introduction................................................................................. 4 Document Conventions............................................................... 4 Typewriter font..................................................................... 4 Italics .................................................................................... 5 [ Brackets ] ........................................................................... 5 Conventions.......................................................................... 6 Command Line ..................................................................... 6 Flags ..................................................................................... 6 Compiler Architecture ................................................................ 8 Predefined Symbol...................................................................... 9 Linking........................................................................................ 9 Programming Support Utilities................................................... 9 Listings...................................................................................... 10 Optimizations............................................................................ 11 Support for Bank Switching ..................................................... 12 Support for ROMable Code...................................................... 12 Support for eeprom ................................................................... 13 Chapter 2 Tutorial Introduction Acia.c, Example file.................................................................. 16 Default Compiler Operation............................................... 17 Compiling and Linking............................................................. 18 Step 1: Compiling............................................................... 18 Step 2: Assembler............................................................... 19 Step 3: Linking ................................................................... 20 Step 4: Generating S-Records file ...................................... 23 Linking Your Application......................................................... 24 Generating Automatic Data Initialization................................. 25 Specifying Command Line Options ......................................... 27 Chapter 3 Programming Environments Introduction............................................................................... 30 Modifying the Runtime Startup ................................................ 32 (i) Description of Runtime Startup Code ................................ 32 Initializing data in RAM........................................................... 33 The const and volatile Type Qualifiers..................................... 36 Performing Input/Output in C................................................... 37 Placing Data Objects in The Bss Section ................................. 38 Placing Data Objects in The Zero Page Section....................... 38 Placing Data Objects in the EEPROM Space........................... 40 Redefining Sections.................................................................. 41 Inlining Functions..................................................................... 43 Optimizing boolean functions .................................................. 44 Referencing Absolute Addresses.............................................. 44 Accessing Internal Registers .................................................... 46 Inserting Inline Assembly Instructions..................................... 47 Inlining with pragmas......................................................... 47 Inlining with _asm.............................................................. 48 Inlining Labels.................................................................... 50 Writing Interrupt Handlers ....................................................... 51 Placing Addresses in Interrupt Vectors .................................... 52 Calling a Bank Switched Function ........................................... 53 Accessing Banked Data ............................................................ 55 Using Position Independent Code ............................................ 57 Fuzzy Logic Support ................................................................ 58 Interfacing C to Assembly Language ....................................... 59 Register Usage.......................................................................... 60 Stack Model........................................................................ 61 Stack Representation .......................................................... 61 Heap Management Control with the C Compiler..................... 63 Modifying The Heap Location........................................... 65 Data Representation.................................................................. 68 Chapter 4 Using The Compiler Invoking the Compiler.............................................................. 72 Compiler Command Line Options ..................................... 73 File Naming Conventions......................................................... 79 Generating Listings................................................................... 80 Generating an Error File ........................................................... 80 Return Status............................................................................. 80 Examples .................................................................................. 80 C Library Support..................................................................... 81 How C Library Functions are Packaged............................. 81 Inserting Assembler Code Directly .................................... 81 (ii) Linking Libraries with Your Program................................ 81 Integer Library Functions................................................... 81 Common Input/Output Functions....................................... 82 Functions Implemented as Macros..................................... 82 Functions Implemented as Builtins .................................... 83 Including Header Files ....................................................... 83 Descriptions of C Library Functions ........................................ 85 Generate inline assembly code ........................................... 86 Abort program execution.................................................... 87 Find absolute value............................................................. 88 Arccosine............................................................................ 89 Arcsine................................................................................ 90 Arctangent .......................................................................... 91 Arctangent of y/x................................................................ 92 Convert buffer to double .................................................... 93 Convert buffer to integer .................................................... 94 Convert buffer to long ........................................................ 95 Allocate and clear space on the heap.................................. 96 Test or get the carry bit....................................................... 97 Round to next higher integer .............................................. 98 Verify the recorded checksum............................................ 99 Verify the recorded checksum.......................................... 100 Verify the recorded checksum.......................................... 101 Verify the recorded checksum.......................................... 102 Cosine............................................................................... 103 Hyperbolic cosine............................................................. 104 Divide with quotient and remainder................................. 105 Copy a buffer to an eeprom buffer ................................... 106 Erase the full eeprom space.............................................. 107 Propagate fill character throughout eeprom buffer .......... 108 Exit program execution .................................................... 109 Exponential....................................................................... 110 Find double absolute value............................................... 111 Copy a moveable code segment in RAM......................... 112 Round to next lower integer ............................................. 113 Find double modulus ........................................................ 114 Free space on the heap...................................................... 115 Extract fraction from exponent part ................................. 116 Get character from input stream ....................................... 117 Get a text line from input stream...................................... 118 Test for alphabetic or numeric character.......................... 119 Test for alphabetic character ............................................ 120 (iii) Test for control character ................................................. 121 Test for digit ....................................................................
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages502 Page
-
File Size-