Specifications

CAVR-4
Part 1. Using the compiler
Data storage
17
Note that the location of the pointer variable p is not affected by the keyword. In the
following example, however, the pointer variable
p2 is placed in far memory. Like p, p2
points to a character in EEPROM memory.
char __eeprom * __far p2;
Type definitions
Storage can also be specified using type definitions. The following two declarations are
equivalent:
typedef char __far Byte;
typedef Byte *BytePtr;
Byte b;
BytePtr bp;
and
__far char b;
char __far *bp;
Memory models
The AVR IAR C/C++ Compiler supports a number of memory models that can be used
for applications with different data requirements.
Technically, the memory model specifies the default memory type attribute and default
data pointer attribute. This means that the memory model controls the following:
The placement of static and global variables, as well as constant literals
Dynamically allocated data, for example data allocated with malloc, or, in C++,
the operator
new
The default pointer type
The placement of the runtime stack.
The memory model only specifies the default memory type. It is possible to override this
for individual variables and pointers. For information about how to specify a memory
type for individual objects, see Using data memory attributes, page 19.
SPECIFYING A MEMORY MODEL
Three memory models are implemented: Tiny, Small, and Large. These models are
controlled by the --memory_model option. Each memory model has a default memory
type and a default pointer size. The code size will also be reduced somewhat if the Tiny
or Small memory model is used.