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

製品コード
SW006021-1
ページ / 518
C Language Features
 2012 Microchip Technology Inc.
DS52053B-page 185
If this construct is used with interrupt functions it will only affect the position of the code 
associated with the interrupt function body. The interrupt context switch code that pre-
cedes the function code will not be relocated as it must be linked to the interrupt vector. 
See also Section4.8.22 “--CODEOFFSET: Offset Program Code to Address” for 
information on how to move Reset and interrupt vector locations, which may be useful 
for designing applications such as bootloaders.
Unlike absolute variables, the generated code associated with absolute functions is still 
placed in a psect, but the psect is dedicated to that function only. The psect name has 
the form below. A full list of all psect names are listed in Section 5.10 “Main, Runtime 
Startup and Reset”
.
xxx_text 
Defines the psect for a function that has been made absolute; i.e., placed 
at an address. xxx will be the assembly symbol associated with the function. 
For example if the function rv() is made absolute, code associated with it 
will appear in the psect called _rv_text.
Functions can also be placed at specific positions by using the psect pragma, see 
Section 5.14.4.8 “The #pragma psect Directive”. The decision whether functions 
should be positioned this way or using absolute functions should be based on the 
location requirements.
Using absolute functions is the easiest method, but only allows placement at an 
address which must be known prior to compilation. The psect pragma is more com-
plex, but offers all the flexibility of the linker to position the new psect into memory. For 
example, you can specify that functions reside at a fixed address, or that they be placed 
after other psects, or that the they be placed anywhere in a compiler-defined or 
user-defined range of addresses.
5.8.5
Function Size Limits
For all devices, the code generated for a function is only limited only by the available 
program memory. Functions may become larger than one page in size on paged 
devices; however, these functions may not be as efficient due to longer call sequences 
to jump to and call destinations in other pages. See 5.8.3 “Allocation of Executable 
Code”
 fo
r more details.
5.8.6
Function Parameters
MPLAB XC8 uses a fixed convention to pass arguments to a function. The method 
used to pass the arguments depends on the size and number of arguments involved.
The compiler will either pass arguments in the W register, or in the called function’s 
parameter memory in its auto-parameter block (APB). If the first parameter is one byte 
in size, it is passed in the W register. All other parameters are passed in the APB. This 
applies to basic types and to aggregate types, like structures.
The parameters are grouped along with the function’s auto variables in the APB and 
are placed in the compiled stack. SeSection 5.5.2.2.1 “Compiled Stack Operation” 
for detailed information on the compiled stack. The parameter variables will be refer-
enced as an offset from the symbol ?_function, where function is the name of the 
function in which the parameter is defined (i.e., the function that is to be called).
Note:
The names “argument” and “parameter” are often used interchangeably, 
but typically an argument is the actual value that is passed to the function 
and a parameter is the variable defined by the function to store the 
argument.