IAR C Compiler Reference Guide for Dallas Semiconductor/Maxim’S MAXQ Microcontroller

Total Page:16

File Type:pdf, Size:1020Kb

IAR C Compiler Reference Guide for Dallas Semiconductor/Maxim’S MAXQ Microcontroller IAR C Compiler Reference Guide for Dallas Semiconductor/Maxim’s MAXQ Microcontroller CMAXQ-6 CMAXQ-6:3 COPYRIGHT NOTICE Copyright © 2004–2010 IAR Systems AB. No part of this document may be reproduced without the prior written consent of IAR Systems AB. The software described in this document is furnished under a license and may only be used or copied in accordance with the terms of such a license. DISCLAIMER The information in this document is subject to change without notice and does not represent a commitment on any part of IAR Systems. While the information contained herein is assumed to be accurate, IAR Systems assumes no responsibility for any errors or omissions. In no event shall IAR Systems, its employees, its contractors, or the authors of this document be liable for special, direct, indirect, or consequential damage, losses, costs, charges, claims, demands, claim for lost profits, fees, or expenses of any nature or kind. TRADEMARKS IAR Systems, IAR Embedded Workbench, C-SPY, visualSTATE, From Idea To Target, IAR KickStart Kit, IAR PowerPac, IAR YellowSuite, IAR Advanced Development Kit, IAR, and the IAR Systems logotype are trademarks or registered trademarks owned by IAR Systems AB. J-Link is a trademark licensed to IAR Systems AB. Microsoft and Windows are registered trademarks of Microsoft Corporation. Dallas Semiconductor/Maxim is a registered trademark of Dallas Semiconductor/Maxim. MAXQ is a trademark of Dallas Semiconductor/Maxim. Adobe and Acrobat Reader are registered trademarks of Adobe Systems Incorporated. All other product names are trademarks or registered trademarks of their respective owners. EDITION NOTICE Sixth edition: December 2010 Part number: CMAXQ-6 This guide applies to version 2.x of IAR Embedded Workbench® for Dallas Semiconductor/Maxim’s MAXQ microcontroller. Internal reference: T6, T6, IMAE. CMAXQ-6:3 Brief contents Tables ...................................................................................................................... 15 Preface .................................................................................................................... 17 Part 1. Using the compiler ....................................................... 23 Getting started .................................................................................................. 25 Data storage ...................................................................................................... 33 Functions ............................................................................................................... 43 Placing code and data .................................................................................... 51 The DLIB runtime environment .............................................................. 67 The CLIB runtime environment .............................................................. 95 Assembler language interface ................................................................. 103 Efficient coding for embedded applications ...................................... 119 Part 2. Compiler reference .................................................... 131 Compiler usage ................................................................................................ 133 Compiler options ........................................................................................... 139 Data representation ...................................................................................... 167 Compiler extensions .................................................................................... 175 Extended keywords ....................................................................................... 187 Pragma directives ............................................................................................ 197 Intrinsic functions ........................................................................................... 213 The preprocessor ........................................................................................... 217 Library functions ............................................................................................. 223 3 CMAXQ-6:3 Segment reference ......................................................................................... 231 Implementation-defined behavior .......................................................... 239 Index ..................................................................................................................... 253 IAR C Compiler 4 Reference Guide for MAXQ CMAXQ-6:3 Contents Tables ...................................................................................................................... 15 Preface .................................................................................................................... 17 Who should read this guide ............................................................... 17 How to use this guide .......................................................................... 17 What this guide contains ................................................................... 18 Other documentation ........................................................................... 19 Further reading ................................................................................... 19 Document conventions ........................................................................ 20 Typographic conventions ................................................................... 20 Naming conventions .......................................................................... 21 Part 1. Using the compiler ....................................................... 23 Getting started .................................................................................................. 25 IAR language overview ......................................................................... 25 Building applications—an overview ................................................ 25 Compiling ........................................................................................... 26 Linking .............................................................................................. 26 Basic settings for project configuration ........................................ 27 Processor configuration ...................................................................... 27 Data model ......................................................................................... 28 Code model ........................................................................................ 29 Optimization for speed and size ......................................................... 29 Runtime environment ......................................................................... 29 Special support for embedded systems ........................................ 31 Extended keywords ............................................................................ 31 Pragma directives ............................................................................... 31 Predefined symbols ............................................................................ 32 Special function types ........................................................................ 32 Header files for I/O ............................................................................ 32 Accessing low-level features ............................................................. 32 5 CMAXQ-6:3 Data storage ...................................................................................................... 33 Introduction ............................................................................................. 33 Data models .............................................................................................. 34 Specifying a data model ..................................................................... 34 Memory types .......................................................................................... 35 Data8 .................................................................................................. 35 Data16 ............................................................................................... 35 Register ............................................................................................. 36 Using data memory attributes ............................................................ 36 Pointers and memory types ................................................................ 37 Structures and memory types ............................................................ 38 More examples ................................................................................... 39 Constant placement .............................................................................. 39 The stack and auto variables ............................................................. 40 Dynamic memory on the heap ........................................................ 41 Functions ............................................................................................................... 43 Function-related extensions .............................................................. 43 Code models and memory attributes for function storage 43 Small code model ............................................................................... 44 Large code model ............................................................................... 45 Selecting a code model ...................................................................... 45 Primitives
Recommended publications
  • IAR Systems Brings Functional Safety Tools to RISC-V with Certification for IEC 61508 and ISO 26262
    Press release Date: October 20, 2020 IAR Systems brings functional safety tools to RISC-V with certification for IEC 61508 and ISO 26262 Stockholm, Sweden—October 20, 2020— IAR Systems®, the future-proof supplier of software tools and services for embedded development, further extends its strong tools offering for RISC-V by announcing a certified version of its development tools. The functional safety edition of IAR Embedded Workbench® for RISC-V will be certified by TÜV SÜD according to the requirements of IEC 61508, the international umbrella standard for functional safety, as well as ISO 26262, which is used for automotive safety-related systems. In addition, the certification covers the international standard IEC 62304, which specifies life cycle requirements for the development of medical software and software within medical devices, and the European railway standards EN 50128 and EN 50657. “We are seeing RISC-V becoming an important architecture not only in broad designs, but specifically in automotive applications,” said Stefan Skarin, CEO, IAR Systems. “By providing our development tools with certification according to ISO 26262, we enable the RISC-V community to further expand and more rapidly bring functional safety designs to the market. As a commercial tools vendor, we are able to provide global technical support as well as invest in keeping our products robust, maintained and qualified. Our certified tools will enable our customers to speed up the path to using RISC-V in safety-critical applications within automotive and other areas.” “We see a strong demand for RISC-V with safety among our customers, and the certification of IAR Embedded Workbench for RISC-V aligns perfectly with that demand,” said Frankwell Lin, President, Andes Technology.
    [Show full text]
  • IAR Systems Supports New Amazon Web Services Iot Microcontroller Operating System Amazon Freertos at Launch
    Press release Date: November 30, 2017 IAR Systems supports new Amazon Web Services IoT Microcontroller Operating System Amazon FreeRTOS at Launch Amazon FreeRTOS will be supported by the leading embedded development toolchain IAR Embedded Workbench Uppsala, Sweden—November 30, 2017—IAR Systems®, a leading supplier of software tools and services for embedded development, announces support for newly launched Internet of Things (IoT) Microcontroller Operating System, Amazon FreeRTOS. Together with Amazon Web Services (AWS), IAR Systems provides developers with easy access to high-performance, pre-integrated development tools for developing and debugging embedded and IoT-connected applications based on Amazon FreeRTOS. Amazon FreeRTOS provides tools that developers need to quickly and easily deploy a microcontroller- based connected device and develop an embedded or IoT application without having to worry about the complexity of scaling across millions of devices. Based on the FreeRTOS kernel, Amazon FreeRTOS includes software libraries which make it easy to securely connect devices locally to AWS Greengrass, directly to the cloud, and update them remotely. For new devices, developers can choose to build their embedded and IoT application on a variety of qualified microcontrollers from companies collaborating with AWS and IAR Systems, including Microchip, NXP, STMicroelectronics and Texas Instruments. Since 1983, IAR Systems’ solutions have ensured quality, reliability and efficiency in the development of over one million embedded applications. Now available for Amazon FreeRTOS users, development tools from IAR Systems deliver leading code optimizations and extensive debugging functionality. The technology is coupled with professional technical support offered globally. “AWS is pleased to be teamed with IAR Systems to provide developers with access to a high performance, pre-integrated set of development tools for developing and debugging connected applications,” says Richard Barry, Principal Engineer, Amazon Web Services, Inc.
    [Show full text]
  • CS 110 Discussion 15 Programming with SIMD Intrinsics
    CS 110 Discussion 15 Programming with SIMD Intrinsics Yanjie Song School of Information Science and Technology May 7, 2020 Yanjie Song (S.I.S.T.) CS 110 Discussion 15 2020.05.07 1 / 21 Table of Contents 1 Introduction on Intrinsics 2 Compiler and SIMD Intrinsics 3 Intel(R) SDE 4 Application: Horizontal sum in vector Yanjie Song (S.I.S.T.) CS 110 Discussion 15 2020.05.07 2 / 21 Table of Contents 1 Introduction on Intrinsics 2 Compiler and SIMD Intrinsics 3 Intel(R) SDE 4 Application: Horizontal sum in vector Yanjie Song (S.I.S.T.) CS 110 Discussion 15 2020.05.07 3 / 21 Introduction on Intrinsics Definition In computer software, in compiler theory, an intrinsic function (or builtin function) is a function (subroutine) available for use in a given programming language whose implementation is handled specially by the compiler. Yanjie Song (S.I.S.T.) CS 110 Discussion 15 2020.05.07 4 / 21 Intrinsics in C/C++ Compilers for C and C++, of Microsoft, Intel, and the GNU Compiler Collection (GCC) implement intrinsics that map directly to the x86 single instruction, multiple data (SIMD) instructions (MMX, Streaming SIMD Extensions (SSE), SSE2, SSE3, SSSE3, SSE4). Yanjie Song (S.I.S.T.) CS 110 Discussion 15 2020.05.07 5 / 21 x86 SIMD instruction set extensions MMX (1996, 64 bits) 3DNow! (1998) Streaming SIMD Extensions (SSE, 1999, 128 bits) SSE2 (2001) SSE3 (2004) SSSE3 (2006) SSE4 (2006) Advanced Vector eXtensions (AVX, 2008, 256 bits) AVX2 (2013) F16C (2009) XOP (2009) FMA FMA4 (2011) FMA3 (2012) AVX-512 (2015, 512 bits) Yanjie Song (S.I.S.T.) CS 110 Discussion 15 2020.05.07 6 / 21 SIMD extensions in other ISAs There are SIMD instructions for other ISAs as well, e.g.
    [Show full text]
  • PGI Compilers
    USER'S GUIDE FOR X86-64 CPUS Version 2019 TABLE OF CONTENTS Preface............................................................................................................ xii Audience Description......................................................................................... xii Compatibility and Conformance to Standards............................................................xii Organization................................................................................................... xiii Hardware and Software Constraints.......................................................................xiv Conventions.................................................................................................... xiv Terms............................................................................................................ xv Related Publications.........................................................................................xvii Chapter 1. Getting Started.....................................................................................1 1.1. Overview................................................................................................... 1 1.2. Creating an Example..................................................................................... 2 1.3. Invoking the Command-level PGI Compilers......................................................... 2 1.3.1. Command-line Syntax...............................................................................2 1.3.2. Command-line Options............................................................................
    [Show full text]
  • Intel Hardware Intrinsics in .NET Core
    Han Lee, Intel Corporation [email protected] Notices and Disclaimers No license (express or implied, by estoppel or otherwise) to any intellectual property rights is granted by this document. Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade. This document contains information on products, services and/or processes in development. All information provided here is subject to change without notice. Contact your Intel representative to obtain the latest forecast, schedule, specifications and roadmaps. Intel technologies’ features and benefits depend on system configuration and may require enabled hardware, software or service activation. Learn more at intel.com, or from the OEM or retailer. The products and services described may contain defects or errors known as errata which may cause deviations from published specifications. Current characterized errata are available on request. No product or component can be absolutely secure. Copies of documents which have an order number and are referenced in this document may be obtained by calling 1-800-548- 4725 or by visiting www.intel.com/design/literature.htm. Intel, the Intel logo, and other Intel product and solution names in this presentation are trademarks of Intel *Other names and brands may be claimed as the property of others © Intel Corporation. 2 What Do These Have in Common? Domain Example Image processing Color extraction High performance computing (HPC) Matrix multiplication Data processing Hamming code Text processing UTF-8 conversion Data structures Bit array Machine learning Classification For performance sensitive code, consider using Intel® hardware intrinsics 3 Objectives .
    [Show full text]
  • IAR Embedded Workbench® for ARM
    IAR Embedded Workbench® for ARM IAR Embedded Workbench is a set of highly sophisticated • Binary compatibility with other EABI compliant tools and easy-to-use development tools for embedded applica- • Automatic checking of MISRA C rules (MISRA C:2004) tions. It integrates the IAR C/C++ Compiler™, assembler, • Language extensions for embedded applications with linker, librarian, text editor, project manager, and C-SPY® target-speciic support Debugger in an integrated development environment • Advanced inline assembler • Support for ARM, Thumb1 and Thumb-2 processor modes (IDE). With its built-in chip-specific code optimizer, IAR • Support for the VFP9-S loating-point co-processor Embedded Workbench generates very efficient and reliable • Support for 4 Gbyte applications in all processor modes code for ARM devices. In addition to this solid technology, • Support for 64-bit long long IAR Systems also provides professional worldwide technical • 32- and 64-bit loating-point types in standard IEEE format support. • Reentrant code • Position Independent Code and Data (PIC/PID) MODULAR AND EXTENSIBLE IDE • Multiple levels of optimizations on code size and execution • A seamlessly integrated environment for building and speed allowing different transformations enabled, such as debugging embedded applications function inlining, loop unrolling etc. • Powerful project management allowing multiple projects in one workspace STATE-OF-THE-ART C-SPY® DEBUGGER • Build integration with IAR visualSTATE • Complex code and data breakpoints • Hierarchical project
    [Show full text]
  • IAR C/C++ Compiler Reference Guide for V850
    IAR Embedded Workbench® IAR C/C++ Compiler Reference Guide for the Renesas V850 Microcontroller Family CV850-9 COPYRIGHT NOTICE © 1998–2013 IAR Systems AB. No part of this document may be reproduced without the prior written consent of IAR Systems AB. The software described in this document is furnished under a license and may only be used or copied in accordance with the terms of such a license. DISCLAIMER The information in this document is subject to change without notice and does not represent a commitment on any part of IAR Systems. While the information contained herein is assumed to be accurate, IAR Systems assumes no responsibility for any errors or omissions. In no event shall IAR Systems, its employees, its contractors, or the authors of this document be liable for special, direct, indirect, or consequential damage, losses, costs, charges, claims, demands, claim for lost profits, fees, or expenses of any nature or kind. TRADEMARKS IAR Systems, IAR Embedded Workbench, C-SPY, visualSTATE, The Code to Success, IAR KickStart Kit, I-jet, I-scope, IAR and the logotype of IAR Systems are trademarks or registered trademarks owned by IAR Systems AB. Microsoft and Windows are registered trademarks of Microsoft Corporation. Renesas is a registered trademark of Renesas Electronics Corporation. V850 is a trademark of Renesas Electronics Corporation. Adobe and Acrobat Reader are registered trademarks of Adobe Systems Incorporated. All other product names are trademarks or registered trademarks of their respective owners. EDITION NOTICE Ninth edition: May 2013 Part number: CV850-9 This guide applies to version 4.x of IAR Embedded Workbench® for the Renesas V850 microcontroller family.
    [Show full text]
  • Optimizing Subroutines in Assembly Language an Optimization Guide for X86 Platforms
    2. Optimizing subroutines in assembly language An optimization guide for x86 platforms By Agner Fog. Copenhagen University College of Engineering. Copyright © 1996 - 2012. Last updated 2012-02-29. Contents 1 Introduction ....................................................................................................................... 4 1.1 Reasons for using assembly code .............................................................................. 5 1.2 Reasons for not using assembly code ........................................................................ 5 1.3 Microprocessors covered by this manual .................................................................... 6 1.4 Operating systems covered by this manual................................................................. 7 2 Before you start................................................................................................................. 7 2.1 Things to decide before you start programming .......................................................... 7 2.2 Make a test strategy.................................................................................................... 9 2.3 Common coding pitfalls............................................................................................. 10 3 The basics of assembly coding........................................................................................ 12 3.1 Assemblers available ................................................................................................ 12 3.2 Register set
    [Show full text]
  • Tools from IAR Systems for Freescale Kinetis Microcontrollers
    Tools from IAR Systems for Freescale Kinetis Microcontrollers IAR Embedded Workbench IAR KickStart Kit for Kinetis IIAR Embedded Workbench is a set of highly sophisticated and easy- IAR KickStart kit for Kinetis K60 contains all the necessary hardware to-use software development tools for Freescale Kinetis. It integrates and software for designing, developing, integrating and testing applica- the IAR C/C++ Compiler, assembler, linker, librarian, text editor, project tions. It includes: manager, and C-SPY Debugger in an integrated development environ- • 32-bit MCU module with MK60N512 MCU ment (IDE). With its built-in chip-specific code optimizer, IAR Embedded • Two elevator modules that provide power regulation circuitry, Workbench generates efficient and reliable FLASHable code for Kinetis standardized signal assignments, and act as common backplane for microcontrollers. all assembled Tower System modules Highlights: • Serial peripheral module with Ethernet, USB, RS232/485, and • Integration of Freescale MQX Software Solutions CAN interface circuitry • Power debugging for minimized power consumption • Prototyping module featuring ample perfboard area for custom • Example projects for MXQ and Tower kit circuitry • Trace debugging supporting ETM and SWD • IAR J-Link Lite for Cortex-M - a small JTAG-emulator with SWD/ • Automatic project configuration for all Kinetis devices SWO debugging support for Cortex-M devices • DVD with software development tools, example projects & RTOS BSPs, training materials and collateral • Quick Start Guide Debug probes IAR J-Link/J-Link Ultra IAR J-Link and IAR J-Link Ultra are compatible high speed JTAG/SWD probes for Kinetis microcontrollers. IAR J-Link Ultra brings better per- formance and is better suited for power debugging compared to IAR J- Link.
    [Show full text]
  • Automatic SIMD Vectorization of Fast Fourier Transforms for the Larrabee and AVX Instruction Sets
    Automatic SIMD Vectorization of Fast Fourier Transforms for the Larrabee and AVX Instruction Sets Daniel S. McFarlin Volodymyr Arbatov Franz Franchetti Department of Electrical and Department of Electrical and Department of Electrical and Computer Engineering Computer Engineering Computer Engineering Carnegie Mellon University Carnegie Mellon University Carnegie Mellon University Pittsburgh, PA USA 15213 Pittsburgh, PA USA 15213 Pittsburgh, PA USA 15213 [email protected] [email protected] [email protected] Markus Püschel Department of Computer Science ETH Zurich 8092 Zurich, Switzerland [email protected] ABSTRACT General Terms The well-known shift to parallelism in CPUs is often associated Performance with multicores. However another trend is equally salient: the increasing parallelism in per-core single-instruction multiple-date Keywords (SIMD) vector units. Intel’s SSE and IBM’s VMX (compatible to Autovectorization, super-optimization, SIMD, program generation, AltiVec) both offer 4-way (single precision) floating point, but the Fourier transform recent Intel instruction sets AVX and Larrabee (LRB) offer 8-way and 16-way, respectively. Compilation and optimization for vector extensions is hard, and often the achievable speed-up by using vec- 1. Introduction torizing compilers is small compared to hand-optimization using Power and area constraints are increasingly dictating microar- intrinsic function interfaces. Unfortunately, the complexity of these chitectural developments in the commodity and high-performance intrinsics interfaces increases considerably with the vector length, (HPC) CPU space. Consequently, the once dominant approach of making hand-optimization a nightmare. In this paper, we present a dynamically extracting instruction-level parallelism (ILP) through peephole-based vectorization system that takes as input the vector monolithic out-of-order microarchitectures is being supplanted by instruction semantics and outputs a library of basic data reorgani- designs with simpler, replicable architectural features.
    [Show full text]
  • IAR J-Link and IAR J-Trace User Guide
    IAR J-Link and IAR J-Trace User Guide for JTAG Emulators for ARM Cores J-Link/J-TraceARM-1 COPYRIGHT NOTICE © Copyright 2006 IAR Systems. All rights reserved. No part of this document may be reproduced without the prior written consent of IAR Systems. The software described in this document is furnished under a license and may only be used or copied in accordance with the terms of such a license. DISCLAIMER The information in this document is subject to change without notice and does not represent a commitment on any part of IAR Systems. While the information contained herein is assumed to be accurate, IAR Systems assumes no responsibility for any errors or omissions. In no event shall IAR Systems, its employees, its contractors, or the authors of this document be liable for special, direct, indirect, or consequential damage, losses, costs, charges, claims, demands, claim for lost profits, fees, or expenses of any nature or kind. TRADEMARKS IAR Systems, From Idea to Target, IAR Embedded Workbench, visualSTATE, IAR MakeApp and C-SPY are trademarks owned by IAR Systems AB. ARM and Thumb are registered trademarks of Advanced RISC Machines Ltd. Microsoft and Windows are registered trademarks of Microsoft Corporation. Intel and Pentium are registered trademarks and XScale a trademark of Intel Corporation. All other product names are trademarks or registered trademarks of their respective owners. EDITION NOTICE First edition: June 2006 Part number: J-Link/J-TraceARM-1 J-Link/J-TraceARM-1 Contents Contents Contents ................................................................................................................. 3 Introduction .......................................................................................................... 7 About this document .............................................................................. 7 Typographic conventions ..................................................................... 7 Literature and references ....................................................................
    [Show full text]
  • H8 IAR C/C++ Compiler Reference Guide
    H8 IAR C/C++ Compiler Reference Guide for Renesas H8/300H and H8S Microcomputer Families CH8-1 COPYRIGHT NOTICE © Copyright 1996–2006 IAR Systems. All rights reserved. No part of this document may be reproduced without the prior written consent of IAR Systems. The software described in this document is furnished under a license and may only be used or copied in accordance with the terms of such a license. DISCLAIMER The information in this document is subject to change without notice and does not represent a commitment on any part of IAR Systems. While the information contained herein is assumed to be accurate, IAR Systems assumes no responsibility for any errors or omissions. In no event shall IAR Systems, its employees, its contractors, or the authors of this document be liable for special, direct, indirect, or consequential damage, losses, costs, charges, claims, demands, claim for lost profits, fees, or expenses of any nature or kind. TRADEMARKS IAR Systems, From Idea to Target, IAR Embedded Workbench, visualSTATE, IAR MakeApp and C-SPY are trademarks owned by IAR Systems AB. Microsoft and Windows are registered trademarks of Microsoft Corporation. All other product names are trademarks or registered trademarks of their respective owners. EDITION NOTICE First edition: June 2006 Part number: CH8-1 This guide applies to version 2.x of H8 IAR Embedded Workbench®. CH8-1 Brief contents Tables ...................................................................................................................... xv Preface .................................................................................................................
    [Show full text]