TASKING VX-Toolset for C166 User Guide TASKING VX-Toolset for C166 User Guide
Total Page:16
File Type:pdf, Size:1020Kb
TASKING VX-toolset for C166 User Guide TASKING VX-toolset for C166 User Guide Copyright © 2006 Altium Limited. All rights reserved.You are permitted to print this document provided that (1) the use of such is for personal use only and will not be copied or posted on any network computer or broadcast in any media, and (2) no modifications of the document is made. Unauthorized duplication, in whole or part, of this document by any means, mechanical or electronic, including translation into another language, except for brief excerpts in published reviews, is prohibited without the express written permission of Altium Limited. Unauthorized duplication of this work may also be prohibited by local statute. Violators may be subject to both criminal and civil penalties, including fines and/or imprisonment. Altium, TASKING, and their respective logos are trademarks or registered trademarks of Altium Limited or its subsidiaries. All other registered or unregistered trademarks referenced herein are the property of their respective owners and no trademark rights to the same are claimed. Table of Contents 1. C Language .................................................................................................................. 1 1.1. Data Types ......................................................................................................... 1 1.2. Changing the Alignment: __unaligned and __packed__ ............................................... 3 1.3. Accessing Memory .............................................................................................. 4 1.3.1. Memory Type Qualifiers .............................................................................. 5 1.3.2. Memory Models ........................................................................................ 8 1.3.3. Allocate an Automatic Object in the MAC accumulator ...................................... 9 1.3.4. Placing an Object at an Absolute Address: __at() and __atbit() ......................... 10 1.3.5. Accessing Hardware from C ...................................................................... 13 1.4. Using Assembly in the C Source: __asm() .............................................................. 15 1.5. Pragmas to Control the Compiler .......................................................................... 18 1.6. Predefined Preprocessor Macros .......................................................................... 22 1.7. Variables .......................................................................................................... 24 1.7.1. Initialized Variables .................................................................................. 24 1.7.2. Non-Initialized Variables ........................................................................... 24 1.8. Strings ............................................................................................................ 25 1.9. Switch Statement ............................................................................................... 25 1.10. Functions ....................................................................................................... 26 1.10.1. Calling Convention ................................................................................. 27 1.10.2. Register Usage ..................................................................................... 29 1.10.3. Inlining Functions: inline .......................................................................... 30 1.10.4. Interrupt Functions ................................................................................. 31 1.10.5. Intrinsic Functions ................................................................................. 33 1.11. Section Naming ............................................................................................... 44 2. C++ Language ............................................................................................................ 47 2.1. C++ Language Extension Keywords ...................................................................... 47 2.2. C++ Dialect Accepted ......................................................................................... 47 2.2.1. Standard Language Features Accepted ....................................................... 48 2.2.2. C++0x Language Features Accepted .......................................................... 51 2.2.3. Anachronisms Accepted ........................................................................... 52 2.2.4. Extensions Accepted in Normal C++ Mode ................................................... 53 2.3. GNU Extensions ................................................................................................ 54 2.4. Namespace Support .......................................................................................... 65 2.5. Template Instantiation ......................................................................................... 67 2.5.1. Automatic Instantiation ............................................................................. 68 2.5.2. Instantiation Modes ................................................................................. 70 2.5.3. Instantiation #pragma Directives ................................................................. 71 2.5.4. Implicit Inclusion ..................................................................................... 73 2.5.5. Exported Templates ................................................................................. 73 2.6. Extern Inline Functions ....................................................................................... 76 2.7. Pragmas to Control the C++ Compiler .................................................................... 77 2.8. Predefined Macros ............................................................................................. 78 2.9. Precompiled Headers ......................................................................................... 82 2.9.1. Automatic Precompiled Header Processing .................................................. 82 2.9.2. Manual Precompiled Header Processing ...................................................... 85 2.9.3. Other Ways to Control Precompiled Headers ................................................ 85 2.9.4. Performance Issues ................................................................................. 86 3. Assembly Language ..................................................................................................... 89 iii TASKING VX-toolset for C166 User Guide 3.1. Assembly Syntax ............................................................................................... 89 3.2. Assembler Significant Characters .......................................................................... 90 3.3. Operands of an Assembly Instruction ..................................................................... 90 3.4. Symbol Names .................................................................................................. 91 3.4.1. Predefined Preprocessor Symbols .............................................................. 91 3.5. Registers ......................................................................................................... 92 3.6. Special Function Registers .................................................................................. 93 3.7. Assembly Expressions ........................................................................................ 93 3.7.1. Numeric Constants .................................................................................. 94 3.7.2. Strings .................................................................................................. 94 3.7.3. Expression Operators .............................................................................. 95 3.7.4. Symbol Types and Expression Types ........................................................... 97 3.8. Built-in Assembly Functions ............................................................................... 100 3.9. Assembler Directives and Controls ...................................................................... 105 3.9.1. Assembler Directives .............................................................................. 105 3.9.2. Assembler Controls ................................................................................ 150 3.10. Macro Operations ........................................................................................... 170 3.10.1. Defining a Macro ................................................................................. 170 3.10.2. Calling a Macro ................................................................................... 170 3.10.3. Using Operators for Macro Arguments ..................................................... 171 3.11. Generic Instructions ........................................................................................ 174 4. Using the C Compiler .................................................................................................. 177 4.1. Compilation Process ......................................................................................... 177 4.2. Calling the C Compiler ...................................................................................... 178 4.3. The C Startup Code .......................................................................................... 180 4.4. How the Compiler Searches Include Files ............................................................. 181 4.5. Compiling