11.07.2015 Views

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Memory types (<strong>MSP430</strong>X only)Type definitionsStorage can also be specified using type definitions. The following two declarations areequivalent:typedef char __data20 Byte;typedef Byte *BytePtr;Byte b;BytePtr bp;and__data20 char b;char __data20 *bp;POINTERS AND MEMORY TYPESPointers are used for referring to the location of data. In general, a pointer has a type.For example, a pointer that has the type int * points to an integer.In the <strong>MSP430</strong> <strong>IAR</strong> C/<strong>C++</strong> <strong>Compiler</strong>, a pointer also points to some type of memory. Thememory type is specified using a keyword before the asterisk. For example, a pointerthat points to an integer stored in data20 memory is declared by:int __data20 * p;Note that the location of the pointer variable p is not affected by the keyword. In thefollowing example, however, the pointer variable p2 is placed in data20 memory. In thiscase, p2 points to a character in data16 memory.char __data16 * __data20 p2;For example, the functions in the standard library are all declared without explicitmemory types.Differences between pointer typesA pointer must contain information needed to specify a memory location of a certainmemory type. This means that the pointer sizes are different for different memory types.For the <strong>MSP430</strong> <strong>IAR</strong> C/<strong>C++</strong> <strong>Compiler</strong>, the size of the data16 and data20 pointers are 16and 32 bits, respectively.In the <strong>MSP430</strong> <strong>IAR</strong> C/<strong>C++</strong> <strong>Compiler</strong>, it is illegal to convert a data20 pointer to a data16pointer without an explicit cast.STRUCTURES AND MEMORY TYPESFor structures, the entire object is placed in the same memory type. It is not possible toplace individual structure members in different memory types.18<strong>MSP430</strong> <strong>IAR</strong> C/<strong>C++</strong> <strong>Compiler</strong>Reference Guide

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!