Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 사용자 설명서
제품 코드
SW006021-1
C Language Features
2012 Microchip Technology Inc.
DS52053B-page 153
5.4.5.2
DATA POINTERS
The MPLAB XC8 compiler monitors and records all assignments of addresses to each
data pointer the program contains. This includes assignment of the addresses of
objects to pointers; assignment of one pointer to another; initialization of pointers when
they are defined; and takes into account when pointers are ordinary variables and func-
tion parameters, and when pointers are used to access basic objects, or structures or
arrays.
data pointer the program contains. This includes assignment of the addresses of
objects to pointers; assignment of one pointer to another; initialization of pointers when
they are defined; and takes into account when pointers are ordinary variables and func-
tion parameters, and when pointers are used to access basic objects, or structures or
arrays.
The size and format of the address held by each pointer is based on this information.
When more than one address is assigned to a pointer at different places in the code, a
set of all possible targets the pointer can address is maintained. This information is spe-
cific to each pointer defined in the program, thus two pointers with the same C type may
hold addresses of different sizes and formats due to the way the pointers were used in
the program.
When more than one address is assigned to a pointer at different places in the code, a
set of all possible targets the pointer can address is maintained. This information is spe-
cific to each pointer defined in the program, thus two pointers with the same C type may
hold addresses of different sizes and formats due to the way the pointers were used in
the program.
The compiler tracks the memory location of all targets, as well as the size of all targets
to determine the size and scope of a pointer. The size of a target is important as well,
particularly with arrays or structures. It must be possible to increment a pointer so it can
access all the elements of an array, for example.
to determine the size and scope of a pointer. The size of a target is important as well,
particularly with arrays or structures. It must be possible to increment a pointer so it can
access all the elements of an array, for example.
There are several pointer classifications used with the MPLAB XC8 C Compiler, such
as those indicated below.
as those indicated below.
For baseline and mid-range devices:
• An 8-bit pointer capable of accessing common memory and two consecutive
banks, e.g., banks 0 and 1, or banks 7 and 8, etc.
• A 16-bit pointer capable of accessing the entire data memory space
• An 8-bit pointer capable of accessing up to 256 bytes of program space data
• A 16-bit pointer capable of accessing up to 64 kbytes of program space data
• A 16-bit mixed target space pointer capable of accessing the entire data space
memory and up to 64 kbytes of program space data
For PIC18 devices:
• An 8-bit pointer capable of accessing the access bank
• A 16-bit pointer capable of accessing the entire data memory space
• An 8-bit pointer capable of accessing up to 256 bytes of program space data
• A 16-bit pointer capable of accessing up to 64 kbytes of program space data
• A 24-bit pointer capable of accessing the entire program space
• A 16-bit mixed target space pointer capable of accessing the entire data space
memory and up to 64 kbytes of program space data
• A 24-bit mixed target space pointer capable of accessing the entire data space
memory and the entire program space
Each data pointer will be allocated one of the available classifications after preliminary
scans of the source code. There is no mechanism by which the programmer can spec-
ify the style of pointer required (other than by the assignments to the pointer). The C
code must convey the required information to the compiler.
scans of the source code. There is no mechanism by which the programmer can spec-
ify the style of pointer required (other than by the assignments to the pointer). The C
code must convey the required information to the compiler.