Variables allocated on the direct page (between 0 and 0xFF) are accessed using direct addressing mode. The Compiler allocates variables on the direct page if you define the variables with a __SHORT_SEG segment.
#pragma DATA_SEG __SHORT_SEG myShortSegment unsigned int myVar1, myVar2; #pragma DATA_SEG DEFAULT unsigned int myvar3, myVar4.
In the previous example, access both myVar1 and myVar2 using direct addressing mode. Access the variables myVar3 and myVar4 using extended addressing mode.
Defining some exported variables in a __SHORT_SEG segment requires that the external declaration for these variables also specify a __SHORT_SEG segment allocation.
#pragma DATA_SEG __SHORT_SEG myShortSegment extern unsigned int myVar1, myVar2; #pragma DATA_SEG DEFAULT extern unsigned int myvar3, myVar4.
Place the segment on the direct page in the PRM file.
LINK test.abs NAMES test.o start08.o ansi.lib END SECTIONS Z_RAM = READ_WRITE 0x0080 TO 0x00FF; MY_RAM = READ_WRITE 0x0100 TO 0x01FF; MY_ROM = READ_ONLY 0xF000 TO 0xFEFF; PLACEMENT DEFAULT_ROM INTO MY_ROM; DEFAULT_RAM INTO MY_RAM; _DATA_ZEROPAGE, myShortSegment INTO Z_RAM; END STACKSIZE 0x60 VECTOR ADDRESS 0xFFFE _Startup /* set reset vector on _Startup */
If all data and stack fits into the zero page, use the tiny memory model for convenience.