The I/O Registers are usually based at address 0. To tell the compiler it must use direct addressing mode to access th e I/O registers, define these registers in a __SHORT_SEG section (if available) based at the specified address.
Define the I/O register in the C source file as in the following listing.
typedef struct { unsigned char SCC1; unsigned char SCC2; unsigned char SCC3; unsigned char SCS1; unsigned char SCS2; unsigned char SCD; unsigned char SCBR; } SCIStruct; #pragma DATA_SEG __SHORT_SEG SCIRegs SCIStruct SCI; #pragma DATA_SEG DEFAULT
Place the segment at the appropriate address in the PRM file (refer the following listing).
LINK test.abs NAMES test.o startup.o ansi.lib END SECTIONS SCI_RG = READ_WRITE 0x0013 TO 0x0019; 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; _ZEROPAGE INTO Z_RAM; SCIRegs INTO SCI_RG; END STACKSIZE 0x60 VECTOR 0 _Startup /* set reset vector on _Startup */