Declare #pragma address in the module in which the variable to be allocated in an absolute address is to be defined. Variables can be allocated to the arbitrary address.
Declare #pragma address in the module in which the variable to be allocated in an absolute address is to be defined. |
Absolute-address : Effective address (binary, octal, decimal, or hexadecimal constant in |
#pragma address should be specified before declaration of the target variable. #pragma address after a variable declaration has no effect (no warning is output). |
If #pragma address is specified for a const-qualified variable, an error will occur. [V1.04 or earlier] |
If #pragma address is specified for a variable declared with an initial value, an error will occur. [V1.04 or earlier] |
If #pragma address is specified for a variable that is not a const-qualified variable and is declared with an initial value, an error will occur. [V1.05 or later] |
If a single address is specified for separate variables or the addresses allocated to separate variables overlap, an error will occur. |
When #pragma address is declared for a variable that is explicitly or implicitly specified as near and if the specified absolute address is not in the range from 0x0F0000 to 0x0FFFFF, a compilation error will occur. If the specified absolute address is in the SFR area, a linkage error will occur. [V1.04 or earlier] |
When #pragma address is declared for a variable that is not a const-qualified variable and is explicitly or implicitly specified as near and if the specified absolute address is not in the range from 0x0F0000 to 0x0FFFFF, a compilation error will occur. If the specified absolute address is in the SFR area, a linkage error will occur. [V1.05 or later] |
When the address specified for a const variable that is explicitly or implicitly specified as near is not in the mirror source area, a linkage error will occur. [V1.05 or later] |
The following shows a sample C source code.
Variables are declared and allocated to sections as follows in the assembly code.
The following code is output in the function.
Even when #pragma address is specified, the volatile attribute is not automatically added to variables. |