Reference Guide a Publication Of
Total Page:16
File Type:pdf, Size:1020Kb
MB299-024-00-00 Doc. ver.: 1.4 M16C v3.0 C Compiler, Assembler, Linker Reference Guide A publication of Altium BV Documentation Department Copyright 2002-2004 Altium BV All rights reserved. Reproduction in whole or part is prohibited without the written consent of the copyright owner. TASKING is a brand name of Altium Limited. The following trademarks are acknowledged: FLEXlm is a registered trademark of Globetrotter Software, Inc. Intel is a trademark of Intel Corporation. Motorola is a registered trademark of Motorola, Inc. MS-DOS and Windows are registered trademarks of Microsoft Corporation. SUN is a trademark of Sun Microsystems, Inc. UNIX is a registered trademark of X/Open Company, Ltd. All other trademarks are property of their respective owners. Data subject to alteration without notice. http://www.tasking.com http://www.altium.com The information in this document has been carefully reviewed and is believed to be accurate and reliable. However, Altium assumes no liabilities for inaccuracies in this document. Furthermore, the delivery of this information does not convey to the recipient any license to use or copy the software or documentation, except as provided in an executed license agreement covering the software and documentation. Altium reserves the right to change specifications embodied in this document without prior notice. CONTENTS TABLE OF CONTENTS IV User's Guide CONTENTS CONTENTS Table of Contents V C LANGUAGE 1-1 1.1 Introduction . 1-3 1.2 Data Types . 1-4 1.3 Keywords . 1-6 1.4 Function Qualifiers . 1-9 1.5 Intrinsic Functions . 1-11 1.5.1 Arithmetic Functions . 1-12 1.5.2 Interrupt Handling . 1-13 1.5.3 Control Register Handling . 1-14 1.5.4 Block Functions . 1-15 1.5.5 Bit Data Functions . 1-15 1.5.6 Miscellaneous Intrinsic Functions . 1-16 1.6 Pragmas . 1-17 1.7 Predefined Macros . 1-22 LIBRARIES 2-1 2.1 Introduction . 2-3 2.2 Library Functions . 2-4 2.2.1 assert.h . 2-4 2.2.2 complex.h . 2-4 2.2.3 ctype.h and wctype.h . 2-6 2.2.4 errno.h . 2-7 2.2.5 fcntl.h . 2-9 2.2.6 fenv.h . 2-9 2.2.7 float.h . 2-10 2.2.8 fss.h . 2-10 2.2.9 inttypes.h and stdint.h . 2-11 2.2.10 iso646.h . 2-12 2.2.11 limits.h . 2-12 2.2.12 locale.h . 2-12 2.2.13 math.h and tgmath.h . 2-13 2.2.14 setjmp.h . 2-20 2.2.15 signal.h . 2-20 2.2.16 stdarg.h . 2-21 •••••••• VI User's Guide 2.2.17 stdbool.h . 2-21 2.2.18 stddef.h . 2-22 2.2.19 stdint.h . 2-22 2.2.20 stdio.h and wchar.h . 2-22 2.2.21 stdlib.h and wchar.h . 2-33 2.2.22 string.h and wchar.h . 2-37 2.2.23 time.h and wchar.h . 2-41 2.2.24 Unistd.h . 2-44 2.2.25 wchar.h . 2-45 2.2.26 wctype.h . 2-46 ASSEMBLY LANGUAGE 3-1 3.1 Introduction . 3-3 3.2 Built-in Assembly Functions . 3-3 3.2.1 Overview of Built-in Assembly Functions . 3-3 3.2.2 Detailed Description of Built-in Assembly Functions . 3-5 3.3 Assembler Directives and Controls . 3-9 3.3.1 Overview of Assembler Directives . 3-9 3.3.2 Detailed Description of Assembler Directives . 3-11 3.3.3 Overview of Assembler Controls . 3-57 3.3.4 Detailed Description of Assembler Controls . 3-57 TOOL OPTIONS 4-1 4.1 Compiler Options . 4-3 4.2 Assembler Options . 4-61 4.3 Linker Options . 4-97 4.4 Control Program Options . 4-144 4.5 Make Utility Options . 4-201 4.6 Archiver Options . 4-230 4.7 Flash Utility Options . 4-243 CONTENTS Table of Contents VII LIST FILE FORMATS 5-1 5.1 Assembler List File Format . 5-3 5.2 Linker Map File Format . 5-5 OBJECT FILE FORMATS 6-1 6.1 ELF/DWARF Object Format . 6-3 6.2 Motorola S-Record Format . 6-4 6.3 Intel Hex Record Format . 6-8 LINKER SCRIPT LANGUAGE 7-1 7.1 Introduction . 7-3 7.2 Structure of a Linker Script File . 7-3 7.3 Syntax of the Linker Script Language . 7-6 7.3.1 Preprocessing . 7-6 7.3.2 Lexical Syntax . 7-6 7.3.3 Identifiers . 7-7 7.3.4 Expressions . 7-7 7.3.5 Built-in Functions . 7-8 7.3.6 LSL Definitions in the Linker Script File . 7-10 7.3.7 Memory and Bus Definitions . 7-11 7.3.8 Architecture Definition . 7-12 7.3.9 Derivative Definition . 7-15 7.3.10 Processor Definition and Board Specification . 7-15 7.3.11 Section Placement Definition . 7-16 7.4 Expression Evaluation . 7-20 7.5 Semantics of the Architecture Definition . 7-21 7.5.1 Defining an Architecture . 7-22 7.5.2 Defining Internal Buses . 7-23 7.5.3 Defining Address Spaces . 7-23 7.5.4 Mappings . 7-26 7.6 Semantics of the Derivative Definition . 7-29 7.6.1 Defining a Derivative . 7-29 7.6.2 Instantiating Core Architectures . 7-30 •••••••• VIII User's Guide 7.6.3 Defining Internal Memory and Buses . 7-31 7.7 Semantics of the Board Specification . 7-33 7.7.1 Defining a Processor . 7-33 7.7.2 Instantiating Derivatives . 7-34 7.7.3 Defining External Memory and Buses . 7-35 7.8 Semantics of the Section Layout Definition . 7-37 7.8.1 Defining a Section Layout . 7-38 7.8.2 Creating and Locating Groups of Sections . 7-39 7.8.3 Creating or Modifying Special Sections . 7-45 7.8.4 Creating Symbols . 7-48 7.8.5 Conditional Group Statements . 7-49 MISRA C RULES 8-1 INDEX CONTENTS Manual Purpose and Structure IX MANUAL PURPOSE AND STRUCTURE Windows Users The documentation explains and describes how to use the M16C toolchain to program an M16C MCU. You can use the tools either with the graphical Embedded Development Environment (EDE) or from the command line in a command prompt window. Unix Users For UNIX the toolchain works the same as it works for the Windows command line. Directory paths are specified in the Windows way, with back slashes as in \cm16c\bin. Simply replace the back slashes by forward slashes for use with UNIX: /cm16c/bin. Structure The toolchain documentation consists of a User's Guide which includes a Getting Started section and a separate Reference Guide (this manual). First you need to install the software and make it run under the licence manager FLEXlm. This is described in Chapter 1, Software Installation and Configuration, of the User's Guide. After installation you are ready to follow the Getting Started in Chapter 2 of the User's Guide. Next, move on with the other chapters in the User's Guide which explain how to use the compiler, assembler, linker and the various utilities. Once you are.