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

製品コード
SW006021-1
ページ / 518
C Language Features
 2012 Microchip Technology Inc.
DS52053B-page 183
This specifier performs the same task as the #pragma inline directive, see 
Section 5.14.4.4 “The #pragma Intrinsic Directive”.
5.8.2
External Functions
If a call to a function that is defined outside the program C source code is required (it 
may be part of code compiled separately, e.g., the bootloader, or in assembly code), 
you will need to provide a declaration of the function so that the compiler knows how to 
encode the call.
If this function takes arguments or returns a value, the compiler may use a symbol to 
represent the memory locations used to store these values, see 
Section 5.8.6 “Function Parameters” anSection 5.8.7 “Function Return Values” 
to determine if a register or memory locations are used in this transfer. Usually, the 
compiler defines this symbol when it encodes the C function, but if the function is exter-
nal and not encoded by the compiler, then the symbol value must be manually defined. 
If an argument or return value is used and this will be stored in memory, the corre-
sponding symbol must be defined by your code and assigned the value of the appro-
priate memory location.
The value can be determined from the map file of the external build, which compiled 
the function, or from the assembly code. If the function was written in C, look for the 
symbol ?_funcName, where funcName is the name of the function. It can be defined 
in the program which makes the call via a simple EQU directive in assembler. For 
example, the following snippet of code could be placed in the C source:
#asm
GLOBAL ?_extReadFn
?_extReadFn EQU 0x20
#endasm
Alternatively, the assembly code could be contained directly in an assembly module. 
This defines the base address of the parameter area for an extern function extReadFn 
to be 0x20.
If this symbol is not defined, the compiler will issue an undefined symbol error. This 
error can be used to verify the name being used by the compiler to encode the call, if 
required.
It is not recommended to call the function indirectly by casting an integer to a function 
pointer, but in such a circumstance, the compiler will use the value of the constant in 
the symbol name, for example calling a function at address 0x200 will require the def-
inition of the symbol ?0x200 to be the location of the parameter/return value location 
for the function. For example:
#asm
GLOBAL ?0x200
?0x200 EQU 0x55
#endasm
Note that the return value of a function (if used) shares the same locations assigned to 
any parameters to that function and both use the same symbol.
5.8.3
Allocation of Executable Code
Code associated with functions is always placed in the program memory of the target 
device.
On baseline and mid-range devices, the program memory is paged (compare: banking 
used in the data memory space). This memory is still sequential (addresses are con-
tiguous across a page boundary), but the paging means that any call or jump from code