Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 ユーザーズマニュアル

製品コード
SW006021-1
ページ / 518
Common C Interface
 2012 Microchip Technology Inc.
DS52053A-page 25
2.5
ANSI STANDARD EXTENSIONS
The following topics describe how the CCI provides device-specific extensions to the 
standard.
2.5.1
Generic Header File
A single header file <xc.h> must be used to declare all compiler- and device-specific 
types and SFRs. You must include this file into every module to conform with the CCI. 
Some CCI definitions depend on this header being seen.
2.5.1.1
EXAMPLE
The following shows this header file being included, thus allowing conformance with the 
CCI, as well as allowing access to SFRs.
#include <xc.h>
2.5.1.2
DIFFERENCES
Some 8-bit compilers used <htc.h> as the equivalent header. Previous versions of 
the 16- and 32-bit compilers used a variety of headers to do the same job.
2.5.1.3
MIGRATION TO THE CCI
Change:
#include <htc.h>
used previously in 8-bit compiler code, or family-specific header files as in the following 
examples:
#include <p32xxxx.h>
#include <p30fxxxx.h>
#include <p33Fxxxx.h>
#include <p24Fxxxx.h>
#include "p30f6014.h"
to:
#include <xc.h>
2.5.2
Absolute addressing
Variables and functions can be placed at an absolute address by using the __at() 
construct.qualifier Note that XC16/32 may require the variable or function to be placed 
in a special section for absolute addressing to work. Stack-based (auto and parame-
ter) variables cannot use the __at() specifier.
2.5.2.1
EXAMPLE
The following shows two variables and a function being made absolute.
int scanMode __at(0x200);
const char keys[] __at(123) = { ’r’, ’s’, ’u’, ’d’};
int modify(int x) __at(0x1000) {
return x * 2 + 3;
}
2.5.2.2
DIFFERENCES
The 8-bit compilers have used an @ symbol to specify an absolute address.
The 16- and 32-bit compilers have used the address attribute to specify an object’s 
address.