Until the next DATA_SEG pragma
#pragma DATA_SEG (<Modif> <Name>|DEFAULT)
DATA_SECTION
__TINY_SEG __SHORT_SEG (compatibility alias: SHORT) __DIRECT_SEG (compatibility alias: DIRECT) __PAGED_SEG __FAR_SEG (compatibility alias: FAR)
__TINY_SEG: specifies an operand that can be encoded on four bits (between 0x0 and 0xF). Use this modifier for frequently accessed global variables.
__SHORT_SEG: specifies an operand that can be encoded on five bits (between 0x0 and 0x1F). Use this modifier to access IO registers in the lower RS08 register bank.
__DIRECT_SEG: specifies an operand that can be encoded within the range 0x00 and 0xBF. Use this modifier to access global variables. If the operand does not fit into either four bits (__TINY_SEG) or five bits (__SHORT_SEG) then direct (8 bit) addressing is used.
__PAGED_SEG: specifies an operand that can be encoded within the range 0x100 and 0x3FF for read/write registers and within the range 0x00 and 0x3FFF for global read-only data. Use this modifier to access IO registers in the high RS08 register bank (read/write) or to access constant data. Objects allocated using __PAGED_SEG must not cross page boundaries.
__FAR_SEG: specifies an operand that can be encoded within the range 0x00 to 0x3FFF. Use this modifier to access large constant (read-only) data. Allocate FAR sections to multiple pages.
<Name>: The name of the segment. This name must be used in the link parameter file on the left side of the assignment in the PLACEMENT part. For more information, refer to the linker manual.
DEFAULT
The DATA_SEG pragma allocates variables into the current data segment. This segment is used to place all variable declarations. Use this pragma to impose tiny or short addressing mode when accessing variables in the relevant sections. Set the default segment with:
#pragma DATA_SEG DEFAULT
When using the -Cc: Allocate Const Objects into ROM compiler option and the ELF object-file format, constants are not allocated in the data segment.
The DATA_SEG pragma also affects data declarations, as well as definitions. Ensure that all variable declarations and definitions are in the same segment.
The RS08 compiler automatically allocates non-static local data into an OVERLAP section. The OVERLAP section uses the same address range as __DIRECT_SEG (0x00 - 0xBF).
Some instructions support tiny and short addressing. These instructions are encoded on one byte only rather than two bytes.
Some compiler optimizations assume that objects having the same segment are together. Backends supporting banked data, for example, may set the page register only once if two accesses to different variables in the same segment are done. This is also the case for the DEFAULT segment. When using a paged access to constant variables, put one segment on one page in the link parameter file.
When #pragma INTO_ROM: Put Next Variable Definition into ROM is active, the current data segment is not used.
The synonym DATA_SECTION means exactly same as DATA_SEG.
The following listing shows source code that uses the DATA_SEG pragma.
/* in a header file */ #pragma DATA_SEG __TINY_SEG MyTinySection char status; #pragma DATA_SEG __ SHORT_SEG MyShortSection unsigned char IOReg; #pragma DATA_SEG DEFAULT char temp; #pragma DATA_SEG __ PAGED_SEG MyShortSection unsigned char IOReg; unsigned char *__paged io_ptr = &IOREG; #pragma DATA_SEG __ PAGED_SEG MyPagedSection const char table[10]; unsigned char *__paged tblptr = table; #pragma DATA_SEG __ FAR_SEG MyFarSection const char table[1000]; unsigned char *__far tblptr = table;
Linker section of the Build Tools manual
#pragma CONST_SEG: Constant Data Segment Definition
#pragma STRING_SEG: String Segment Definition