|
|||||||||||
|
Technical Support On-Line Manuals C251 User's Guide |
C251 User's GuideAbsolute Variable LocationVariables may be located at absolute memory locations in your C program source modules using the _at_ keyword. The usage for this feature is: type[memory_type] variable_name _at_ const_expr; Where
The absolute address following the _at_ keyword must conform to the physical boundaries of the memory space for the variable. For the xdata and code memory types, this expression is interpreted as an offset from the base address of the memory class. The C251 compiler generates the OFFS relocation type for xdata and code variables. Refer to the A251 Assembler User's Guide for more information about relocation expressions. For all other memory types, the _at_ expression represents the absolute memory location in the physical 251 memory. The C251 compiler checks for invalid address specifications. With C251 Version 2 or higher, any type of variable that is defined at module-level may be located on an absolute address. The following example demonstrates how to locate several different variable types using the _at_ keyword. Note
#define base 0x1000 /* base address for declaration */
int near var0 _at_ (base + 10);
int near var1 _at_ (base + 10 + sizeof (var0));
/* locate string at address 0xFFFF80 */
const char far string[12] _at_0xFFFF80 = "TEST PROGRAM";
/* locate text at OFFS 0x7E00, the default gives 0xFF7E00 */
char code text[20] _at_ 0x7E00 = "Hello World\n";
struct led {
char digit0;
char digit1;
};
/* display is accessed at XDATA:0x4000, the default gives 0x014000 */
struct led xdata display _at_ 0x4000;
| ||||||||||
|
|||||||||||