TASKING VX-Toolset for Power Architecture User Guide
Total Page:16
File Type:pdf, Size:1020Kb
TASKING VX-toolset for Power Architecture User Guide MA170-053 (v2.0) March 29, 2012 Copyright © 2012 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. Accessing Memory .............................................................................................. 2 1.2.1. Memory Qualifiers ..................................................................................... 3 1.2.2. Data Allocation Options and Pragmas ........................................................... 4 1.2.3. Data Allocation Threshold Options ................................................................ 5 1.2.4. Allocation of Uninitialized Constants ............................................................. 6 1.2.5. Placing an Object at an Absolute Address: __at() ............................................ 7 1.3. Using Assembly in the C Source: __asm() ................................................................ 8 1.4. Attributes ......................................................................................................... 13 1.5. Pragmas to Control the Compiler .......................................................................... 19 1.6. Predefined Preprocessor Macros .......................................................................... 24 1.7. Switch Statement ............................................................................................... 25 1.8. Functions ......................................................................................................... 31 1.8.1. Calling Convention .................................................................................. 31 1.8.2. Register Usage ....................................................................................... 32 1.8.3. Inlining Functions: inline ........................................................................... 33 1.8.4. VLE Instruction Support: __vle, __novle ....................................................... 34 1.8.5. Floating-Point Unit Support: __fpu, __nofpu .................................................. 35 1.8.6. Interrupt Functions .................................................................................. 35 1.8.7. Intrinsic Functions ................................................................................... 42 1.9. Section Naming ................................................................................................. 46 2. Assembly Language ..................................................................................................... 49 2.1. Assembly Syntax ............................................................................................... 49 2.2. Assembler Significant Characters .......................................................................... 50 2.3. Operands of an Assembly Instruction ..................................................................... 51 2.4. Symbol Names .................................................................................................. 51 2.4.1. Predefined Preprocessor Symbols .............................................................. 52 2.5. Registers ......................................................................................................... 52 2.5.1. Special Purpose Registers (SPRs) ............................................................. 53 2.6. Assembly Expressions ........................................................................................ 53 2.6.1. Numeric Constants .................................................................................. 54 2.6.2. Strings .................................................................................................. 54 2.6.3. Expression Operators .............................................................................. 55 2.7. Working with Sections ......................................................................................... 56 2.8. Built-in Assembly Functions ................................................................................. 57 2.9. Assembler Directives .......................................................................................... 63 2.9.1. Overview of Assembler Directives ............................................................... 63 2.9.2. Detailed Description of Assembler Directives ................................................ 66 2.10. Macro Operations ........................................................................................... 103 2.10.1. Defining a Macro ................................................................................. 103 2.10.2. Calling a Macro ................................................................................... 103 2.10.3. Using Operators for Macro Arguments ..................................................... 104 2.11. Generic Instructions ........................................................................................ 107 3. Using the C Compiler .................................................................................................. 109 3.1. Compilation Process ......................................................................................... 109 3.2. Calling the C Compiler ...................................................................................... 110 3.3. The C Startup Code .......................................................................................... 110 iii TASKING VX-toolset for Power Architecture User Guide 3.4. How the Compiler Searches Include Files ............................................................. 111 3.5. Compiling for Debugging ................................................................................... 112 3.6. Compiler Optimizations ..................................................................................... 112 3.6.1. Generic Optimizations (frontend) .............................................................. 113 3.6.2. Core Specific Optimizations (backend) ....................................................... 116 3.6.3. Optimize for Size or Speed ...................................................................... 117 3.7. Influencing the Build Time .................................................................................. 120 3.8. Static Code Analysis ......................................................................................... 121 3.8.1. C Code Checking: CERT C ...................................................................... 122 3.8.2. C Code Checking: MISRA-C .................................................................... 124 3.9. C Compiler Error Messages ............................................................................... 125 4. Using the Assembler ................................................................................................... 127 4.1. Assembly Process ............................................................................................ 127 4.2. Calling the Assembler ....................................................................................... 128 4.3. How the Assembler Searches Include Files ........................................................... 128 4.4. Assembler Optimizations ................................................................................... 128 4.5. Generating a List File ........................................................................................ 129 4.6. Assembler Error Messages ................................................................................ 129 5. Using the Linker ......................................................................................................... 131 5.1. Linking Process ............................................................................................... 131 5.1.1. Phase 1: Linking .................................................................................... 133 5.1.2. Phase 2: Locating .................................................................................. 134 5.2. Calling the Linker ............................................................................................. 135 5.3. Linking with Libraries ........................................................................................ 136 5.3.1. How the Linker Searches Libraries ............................................................ 137 5.3.2. How the Linker