TASKING VX-Toolset for ARM User Guide
Total Page:16
File Type:pdf, Size:1020Kb
TASKING VX-toolset for ARM User Guide MA101-800 (v4.4) April 15, 2013 Copyright © 2013 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, __packed__ and __align() ................................. 2 1.3. Placing an Object at an Absolute Address: __at() ....................................................... 3 1.4. Accessing Hardware from C .................................................................................. 4 1.5. Using Assembly in the C Source: __asm() ................................................................ 5 1.6. Attributes ......................................................................................................... 11 1.7. Pragmas to Control the Compiler .......................................................................... 15 1.8. Predefined Preprocessor Macros .......................................................................... 20 1.9. Switch Statement ............................................................................................... 21 1.10. Functions ....................................................................................................... 23 1.10.1. Calling Convention ................................................................................. 23 1.10.2. Inlining Functions: inline .......................................................................... 23 1.10.3. Interrupt Functions / Exception Handlers .................................................... 25 1.10.4. Intrinsic Functions ................................................................................. 27 2. C++ Language ............................................................................................................ 37 2.1. C++ Language Extension Keywords ...................................................................... 37 2.2. C++ Dialect Accepted ......................................................................................... 37 2.2.1. Standard Language Features Accepted ....................................................... 37 2.2.2. C++0x Language Features Accepted .......................................................... 40 2.2.3. Anachronisms Accepted ........................................................................... 44 2.2.4. Extensions Accepted in Normal C++ Mode ................................................... 45 2.3. GNU Extensions ................................................................................................ 47 2.4. Namespace Support .......................................................................................... 61 2.5. Template Instantiation ......................................................................................... 63 2.5.1. Automatic Instantiation ............................................................................. 64 2.5.2. Instantiation Modes ................................................................................. 65 2.5.3. Instantiation #pragma Directives ................................................................. 66 2.5.4. Implicit Inclusion ..................................................................................... 67 2.5.5. Exported Templates ................................................................................. 68 2.6. Inlining Functions ............................................................................................... 71 2.7. Extern Inline Functions ....................................................................................... 72 2.8. Pragmas to Control the C++ Compiler .................................................................... 72 2.9. Predefined Macros ............................................................................................. 73 2.10. Precompiled Headers ....................................................................................... 77 2.10.1. Automatic Precompiled Header Processing ................................................. 77 2.10.2. Manual Precompiled Header Processing .................................................... 80 2.10.3. Other Ways to Control Precompiled Headers ............................................... 80 2.10.4. Performance Issues ............................................................................... 81 3. Assembly Language ..................................................................................................... 83 3.1. Assembly Syntax ............................................................................................... 83 3.2. Assembler Significant Characters .......................................................................... 84 3.3. Operands of an Assembly Instruction ..................................................................... 85 3.4. Symbol Names .................................................................................................. 85 3.4.1. Predefined Preprocessor Symbols .............................................................. 86 3.5. Registers ......................................................................................................... 87 3.6. Assembly Expressions ........................................................................................ 87 3.6.1. Numeric Constants .................................................................................. 88 iii TASKING VX-toolset for ARM User Guide 3.6.2. Strings .................................................................................................. 88 3.6.3. Expression Operators .............................................................................. 89 3.7. Working with Sections ......................................................................................... 90 3.8. Built-in Assembly Functions ................................................................................. 91 3.9. Assembler Directives .......................................................................................... 96 3.9.1. Overview of Assembler Directives ............................................................... 97 3.9.2. Detailed Description of Assembler Directives ................................................ 98 3.10. Macro Operations ........................................................................................... 137 3.10.1. Defining a Macro ................................................................................. 137 3.10.2. Calling a Macro ................................................................................... 137 3.10.3. Using Operators for Macro Arguments ..................................................... 138 3.11. Generic Instructions ........................................................................................ 141 3.11.1. ARM Generic Instructions ...................................................................... 141 3.11.2. ARM and Thumb-2 32-bit Generic Instructions ........................................... 142 3.11.3. Thumb 16-bit Generic Instructions ........................................................... 144 4. Using the C Compiler .................................................................................................. 147 4.1. Compilation Process ......................................................................................... 147 4.2. Calling the C Compiler ...................................................................................... 148 4.3. How the Compiler Searches Include Files ............................................................. 150 4.4. Compiling for Debugging ................................................................................... 151 4.5. Compiler Optimizations ..................................................................................... 151 4.5.1. Generic Optimizations (frontend) .............................................................. 153 4.5.2. Core Specific Optimizations (backend) ....................................................... 155 4.5.3. Optimize for Size or Speed ...................................................................... 157 4.6. Influencing the Build Time .................................................................................. 160 4.7. Static Code Analysis ......................................................................................... 163 4.7.1. C Code Checking: CERT