Technical information

AN2216/D
4 MC9S12DP256 Software Development Using Metrowerk’s Codewarrior MOTOROLA
const int *far ptr;
declares a pointer to a constant in paged memory. This pointer may be used to
access variables in paged memory. The MC9S12DP256 does not have
hardware support for far pointers, so if the code which uses this pointer is also
in paged memory, an intermediate runtime routine call will be inserted by the
compiler.
Compiler Memory
Models
The Metrowerks Codewarrior compiler for the MC68HC12 supports three
different memory models. The default is the SMALL memory model which
corresponds to a flat memory map of up to 64k byte of code addressing. By
default, all functions are of type 'near' in the SMALL memory model. The
BANKED memory model supports paged addressing of code. By default, all
user defined functions are of type 'far' in the BANKED memory model. 'Far' data
pointers may be used in both the SMALL and BANKED memory models. The
LARGE memory model supports both paged code and data by default. All
functions and data pointers are of type 'far' in the LARGE memory model. Due
to the increased overhead of the necessary runtime routines, this memory
model is not widely used. The BANKED memory model best suits most
applications of the MC9S12DP256.
Segmentation The Codewarrior compiler supports the concept of segmentation. This means
that code and global variables may be separated into groups which are
allocated to specific memory address spaces by the linker. The attributes
specify the calling mechanism that the compiler must use when generating
code. Code and global variables are allocated segment names and attributes
by means of #pragma statements within the source code.
Code Segment
#pragma CODE_SEG [NEAR | FAR] <segment_name>
#pragma CODE_SEG defines a code segment. The possible attributes include
NEAR and FAR. NEAR specifies that the functions in the segment are called
with a JSR instruction, i.e. the functions in the segment must only be called by
functions in the same page, or must be in non-paged memory. FAR specifies
that the functions in the segment are called with a CALL instruction, i.e there is
no restriction on where they may be located in the memory. If the attribute is
omitted, the default attribute of the specified memory model is assumed. In the
case of the BANKED memory model, the default attribute is FAR. If no segment
is specified, the code will be assigned to the default segment DEFAULT_ROM.
To explicitly assign the default segment, use the segment name DEFAULT. All
functions following the #pragma CODE_SEG statement are included in the