Pragma intrinsic and more

Similar documents
Migrating from Keil µvision for 8051 to IAR Embedded Workbench for 8051

Migrating from Keil µvision for 8051 to IAR Embedded Workbench for 8051

Computer Systems Lecture 9

IAR Embedded Workbench Migration Guide

Chapter 10. Programming in C

M16C/R8C IAR C/C++ Compiler Reference Guide. for Renesas M16C/1X 3X, 6X, and R8C Series of CPU Cores

dspic IAR C/EC++ Compiler Reference Guide for Microchip s dspic Microcontroller Family

V850 Calling Convention

The New C Standard (Excerpted material)

Emprog. Quick Start Guide. Emprog ThunderBench MSP430 FAQ. Version 1.2. Nov Page 1

MPLAB C1X Quick Reference Card

Final CSE 131B Spring 2004

Mating Assembly with C

Viewing the tm4c123gh6pm_startup_ccs.c file, the first piece of code we see after the comments is shown in Figure 1.

TMS470 ARM ABI Migration

CPEG421/621 Tutorial

Summer 2003 Lecture 14 07/02/03

Skip the FFI! Embedding Clang for C Interoperability. Jordan Rose Compiler Engineer, Apple. John McCall Compiler Engineer, Apple

Target Definition Builder. Software release 4.20

WIND RIVER DIAB COMPILER

ME 4447/ME Microprocessor Control of Manufacturing Systems/ Introduction to Mechatronics. Instructor: Professor Charles Ume

DSP Mapping, Coding, Optimization

Program SoC using C Language

CSE 230 Intermediate Programming in C and C++

IAR C/C++ Compiler Reference Guide

Assembler Programming. Lecture 10

Important From Last Time

Page 1. Today. Important From Last Time. Is the assembly code right? Is the assembly code right? Which compiler is right?

Important From Last Time

AVR IAR Embedded Workbench IDE Migration Guide. for Atmel Corporation s AVR Microcontroller

AVR32 IAR C/C++ Compiler Reference Guide. for Atmel Corporation s AVR32 RISC Microprocessor Core

Roadmap. Java: Assembly language: OS: Machine code: Computer system:

ME 4447/6405 Introduction to Mechatronics Instructor: Professor Charles Ume

Short Notes of CS201

Getting Started with the MSP430 IAR Assembly

CS201 - Introduction to Programming Glossary By

Tokens, Expressions and Control Structures

Technical Note (8 & 16-bits) TN 234

RELEASE NOTES: GNURL78 v KPIT Technologies Limited is releasing the GNURL78 v15.02, a cross compiler tool for Renesas RL78 micro-controllers.

IAR Embedded Workbench Migration Guide

A Microprocessor Systems Fall 2009

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

Computers Programming Course 5. Iulian Năstac

Stream Computing using Brook+

CSE 333 Lecture 2 Memory

CPE 323: Laboratory Assignment #1 Getting Started with the MSP430 IAR Embedded Workbench

IAR C Compiler Reference Guide. for Freescale s S08 Microprocessor Family

Run time environment of a MIPS program

EL6483: Brief Overview of C Programming Language

CS241 Computer Organization Spring Data Alignment

Getting Started. with IAR Embedded Workbench GSEW-2

C LANGUAGE AND ITS DIFFERENT TYPES OF FUNCTIONS

ZiLOG Z8 Encore! Compiler Compliance With ANSI STANDARD C

ARM Assembler Workbook. CS160 Computer Organization Version 1.1 October 27 th, 2002 Revised Fall 2005

Holtek C Compiler V3 FAQ

Structures, Unions Alignment, Padding, Bit Fields Access, Initialization Compound Literals Opaque Structures Summary. Structures

TPF Users Group Spring 2006

What's in the software package

Introduction to Programming Using Java (98-388)

CS504 4 th Quiz solved by MCS GROUP

EE475 Lab #3 Fall Memory Placement and Interrupts

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

Known Bugs in ETEC Version 1.31

NEW CEIBO DEBUGGER. Menus and Commands

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C

IAR C/C++ Development Guide Compiling and linking

>B<82. 2Soft ware. C Language manual. Copyright COSMIC Software 1999, 2001 All rights reserved.

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19

Midterm CSE 131B Spring 2005

Lecture 3: C Programm

The X86 Assembly Language Instruction Nop Means

Operating Systems CMPSCI 377, Lec 2 Intro to C/C++ Prashant Shenoy University of Massachusetts Amherst

FUNCTION POINTERS. int (*pf)(); // pf is a pointer to a function returning an int.

Memory Allocation Techniques in System with Dynamic Swapping of Application Codes

Why VC++ instead of Dev C++?

5.Coding for 64-Bit Programs

Table of Contents 1. Chip Configuration TARGET CHIP TARGET CLOCK TARGET FUSES TARGET opt tags

COMP 7860 Embedded Real- Time Systems: Threads

CS356: Discussion #6 Assembly Procedures and Arrays. Marco Paolieri

Assembly Language for Intel-Based Computers, 4 th Edition. Lecture 25: Interface With High-Level Language

SC100 Application Binary Interface. MNSC100ABI/D Rev. 2.0, 06/2002

Summer 2003 Lecture 15 07/03/03

Fundamentals of Programming

a data type is Types

Introduction. Keywords: MAXQ, IAR, memory allocation, flash data, flash storage, SRAM

How to set Keil compiler environment v1.0

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

Quick Reference Guide

G52CPP C++ Programming Lecture 6. Dr Jason Atkin

Quiz Start Time: 09:34 PM Time Left 82 sec(s)

Part 1: Introduction to the C Language

ECE 448 Lecture 9. Bare Metal System Software Development

Stack Frames. September 2, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 September 2, / 15

CS201 Latest Solved MCQs

Informatica e Sistemi in Tempo Reale

Generic access_type descriptor for the Embedded C Technical Report by Jan Kristoffersen Walter Banks

AS08-C++ and Assembly Calling and Returning. CS220 Logic Design AS08-C++ and Assembly. AS08-C++ and Assembly Calling Conventions

DECLARAING AND INITIALIZING POINTERS

Quick Reference Guide

Final CSE 131B Winter 2003

Transcription:

Pragma intrinsic and more C Language Extensions: This section gives a brief overview of the C language extensions available in the MSP430 IAR C/C++ Compiler. The compiler provides a wide set of extensions, so to help you to find the extensions required by your application, the extensions have been grouped according to their expected usefulness. In short, this means: Important language extensions extensions specifically tailored for efficient embedded programming, typically to meet memory restrictions Useful language extensions features considered useful and typically taken from related standards, such as C99 and C++ Minor language extensions, that is, the relaxation of some minor standards issues and also some useful but minor syntax extensions. What is #PRAGMA? The #pragma directive is defined by the ISO/ANSI C standard and is a mechanism for using vendor-specific extensions in a controlled way to make sure that the source code is still portable. The pragma directives control the behavior of the compiler, for example how it allocates memory for variables and functions, whether it allows extended keywords, and whether it outputs warning messages. The pragma directives are always enabled in the compiler.

Placement at an absolute address or in a named segment The @ operator or the directive #pragma location can be used for placing global and static variables at absolute addresses, or placing a variable or function in a named segment. Alignment Each data type has its own alignment. If you want to change alignment, the #pragma pack and #pragma data_alignment are available Dedicated segment operators segment_begin and segment_end The syntax for these operators are: void * segment_begin(segment) void * segment_end(segment) These operators return the address of the first byte of the named segment and the first byte after the named segment, respectively. This can be useful if you have used the @ operator or the #pragma location directive to place a data object or a function in a user-defined segment. The named segment must be a string literal that has been declared earlier with the #pragma segment directive. Example: #pragma segment="myseg"... segment_start_address = segment_begin("myseg");

PACK The #pragma pack directive is used for changing the alignment requirements of the members of a structure. This will change the way the layout of the structure is performed. The members will be placed in the same order as when declared, but there might be less pad space between members.

segment Syntax #pragma segment="segment_name" [align] Parameters "SEGMENT_NAME" align The name of the segment Aligns the segment part. The value must be a constant integer expression to the power of two. Use this pragma directive to declare a segment name that can be used by the segment operators segment_begin and segment_end. Example #pragma segment="myseg" 4 vector Syntax #pragma vector=vector1[, vector2, vector3,...] Parameters vector The vector number(s) of an interrupt or trap function. Use this pragma directive to specify the vector(s) of an interrupt or trap function whose declaration follows the pragma directive. Example #pragma vector=0x14 interrupt void my_handler(void); location Syntax #pragma location={address SEGMENT_NAME} Parameters address The absolute address of the global or static variable for which you want an absolute location. SEGMENT_NAME A user-defined segment name; cannot be a segment name predefined for use by the compiler and linker. Use this pragma directive to specify the location the absolute address of the global or static variable whose declaration follows the pragma directive Example #pragma location="foo" char PORT1; /* PORT1 is located in segment foo */

optimize Syntax #pragma optimize=param[, param,...] Parameters s z 2 none 3 low 6 medium 9 high Optimizes for speed Optimizes for size Specifies the level of optimization

USEFUL LANGUAGE EXTENSIONS Inline functions The #pragma inline directive, alternatively the inline keyword, advises the compiler that the function whose declaration follows immediately after the directive should be inlined. inline Syntax #pragma inline[=forced] Parameters Use this pragma directive to advise the compiler that the function whose declaration follows immediately after the directive should be inlined that is, expanded into the body of the calling function. Whether the inlining actually takes place is subject to the compiler s heuristics. Specifying #pragma inline=forced disables the compiler s heuristics and forces inlining.

Intrinsic functions The intrinsic functions provide direct access to low-level processor operations and can be very useful in, for example, time-critical routines. The intrinsic functions compile into inline code, either as a single instruction or as a short sequence of instructions.

bis_sr_register Syntax void bis_sr_register(unsigned short); Sets bits in the status register. The function takes an integer literal as its argument, that is, a bit mask with the bits to be set. enable_interrupt Syntax void enable_interrupt(void); Enables interrupts by inserting the EINT instruction. get_sp_register Syntax unsigned short get_sp_register(void); Returns the value of the stack pointer register SP. no_operation Syntax void no_operation(void); Inserts a NOP instruction.

Inline assembler The syntax is: asm ("string"); The string can be a valid assembler instruction or a data definition assembler directive, but not a comment. You can write several consecutive inline assembler instructions, for example: asm ("Label: nop\n" " jmp Label"); where \n (new line) separates each new assembler instruction