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 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