IAR C/C++ Compilers Reference Guide for the Renesas 78K0/78K0S and 78K0R Microcontroller Subfamilies
Total Page:16
File Type:pdf, Size:1020Kb
IAR C/C++ Compilers Reference Guide for the Renesas 78K0/78K0S and 78K0R Microcontroller Subfamilies C78K-4 C78K-4:1 COPYRIGHT NOTICE Copyright © 2000–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. Renesas is a registered 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 Fourth edition: May 2010 Part number: C78K-4 This guide applies to version 4.7 of IAR Embedded Workbench® for Renesas Electronics’ 78K0/78K0S and 78K0R Microcontroller Subfamilies. Internal reference: R13, Too6.0, IMAE. C78K-4:1 Brief contents Tables ..................................................................................................................... xix Preface ................................................................................................................... xxi Part 1. Using the compilers ....................................................... 1 Getting started .................................................................................................... 3 Data storage ...................................................................................................... 11 Functions ............................................................................................................... 21 Placing code and data .................................................................................... 39 The DLIB runtime environment .............................................................. 53 The CLIB runtime environment .............................................................. 83 Assembler language interface ................................................................... 91 Using C++ .......................................................................................................... 109 Efficient coding for embedded applications ...................................... 123 Part 2. Reference information ........................................... 141 External interface details ............................................................................ 143 Compiler options ........................................................................................... 149 Data representation ...................................................................................... 181 Compiler extensions .................................................................................... 193 Extended keywords ....................................................................................... 203 Pragma directives ............................................................................................ 217 Intrinsic functions ........................................................................................... 233 The preprocessor ........................................................................................... 237 iii C78K-4 Library functions ............................................................................................. 243 Segment reference ......................................................................................... 253 Implementation-defined behavior .......................................................... 267 Index ..................................................................................................................... 281 IAR C/C++ Compilers iv Reference Guide for 78K C78K-4 Contents Tables ..................................................................................................................... xix Preface ................................................................................................................... xxi Who should read this guide ..............................................................xxi How to use this guide .........................................................................xxi What this guide contains .................................................................xxii Other documentation ........................................................................xxiii Further reading ................................................................................xxiv Document conventions .....................................................................xxiv Typographic conventions ................................................................. xxv Naming conventions ........................................................................ xxv Part 1. Using the compilers ....................................................... 1 Getting started .................................................................................................... 3 IAR language overview ........................................................................... 3 Supported 78K devices ........................................................................... 4 Building applications—an overview .................................................. 4 Compiling ............................................................................................. 5 Linking ................................................................................................ 5 Basic settings for project configuration .......................................... 6 Processor core ..................................................................................... 6 Code model .......................................................................................... 7 Data model (78K0R only) .................................................................... 7 Optimization for speed and size ........................................................... 7 Runtime environment ........................................................................... 8 Special support for embedded systems .......................................... 9 Extended keywords ............................................................................ 10 Pragma directives ............................................................................... 10 Predefined symbols ............................................................................ 10 Special function types ........................................................................ 10 Accessing low-level features ............................................................. 10 v C78K-4 Data storage ...................................................................................................... 11 Introduction ............................................................................................. 11 Different ways to store data ............................................................... 11 Data models (78K0R only) .................................................................. 12 Specifying a data model ..................................................................... 12 Memory types .......................................................................................... 13 Short address Area ............................................................................. 14 Near .................................................................................................... 14 Far (78K0R only) ............................................................................. 14 SFR ..................................................................................................... 14 Using data memory attributes ............................................................ 14 Pointers and memory types ................................................................ 16 Structures and memory types ............................................................ 16 More examples ................................................................................... 17 C++ and memory types ...................................................................... 17 Auto variables—on the stack ............................................................ 18 The stack ............................................................................................ 18 Dynamic memory on the heap ........................................................ 20 Functions ............................................................................................................... 21 Function-related extensions .............................................................. 21 Code models and memory