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

製品コード
SW006021-1
ページ / 518
How To’s
 2012 Microchip Technology Inc.
DS52053B-page 49
3.4.2.5
HOW DO I FIND THE NAMES USED TO REPRESENT SFRS AND BITS?
Special function registers and the bits within those are accessed via special variables 
that map over the register, Section 3.4.2.4 “How Do I Access SFRs?”; however, the 
names of these variables sometimes differ from those indicated in the data sheet for 
the device you are using.
You can work your way through the <xc.h> header file to find the device-specific 
header file which allows access to these special variables, but an easier way is to look 
in any of the preprocessed files left behind after a previous compilation. These file have 
a .pre extension and there will be one file with the same base name as each source 
file in your project. Look in the preprocessed file for any source file that include <xc.h> 
as this will include the definition for all the SFR variables and bits within those.
If you are compiling under MPLAB X IDE, the preprocessed file(s) are left under the 
build/default/production
 directory of your project for regular builds, or under 
build/default/debug
 for debug builds. The are typically left in the source file direc-
tory if you are compiling on the command line.
3.4.3
Memory Allocation
Here are questions relating to how your source code affects memory allocation.
3.4.3.1
HOW DO I POSITION VARIABLES AT AN ADDRESS I NOMINATE?
The easiest way to do this is to make the variable absolute, by using the @ address 
construct, see Section 5.5.4 “Absolute Variables”. This means that the address you 
specify is used in preference to the variable’s symbol in generated code. Since you 
nominate the address, you have full control over where objects are positioned, but you 
must also ensure that absolute variables do not overlap. Variables placed in the middle 
of banks can cause havoc with the allocation of other variables and lead to "Can’t find 
space" errors, see Section 3.7.6 “How Do I Fix a "Can’t find space..." Error?”. See 
also Section 5.5.2.4 “Changing the Default Auto Variable Allocation” for informa-
tion on moving auto variables, Section 5.5.2.1.3 “Changing the Default Non-Auto 
Variable Allocation”
 for moving non-auto variables anSection 5.5.3.2 “Changing 
the Default Allocation”
 for
 moving program-space variables.
3.4.3.2
HOW DO I POSITION FUNCTIONS AT AN ADDRESS I NOMINATE?
The easiest way to do this is to make the functions absolute, by using the @ address 
construct, see Section 5.8.4 “Changing the Default Function Allocation”. This 
means that the address you specify is used in preference to the variable’s symbol in 
generated code. Since you nominate the address, you have full control over where 
functions are positioned, but must also ensure that absolute functions do not overlap. 
Functions placed in the middle of pages can cause havoc with the allocation of other 
functions and lead to "Can’t find space" errors, seSection 3.7.6 “How Do I Fix a 
"Can’t find space..." Error?”
.