313/317
10 - Second Application: a Sailing Computer
ARAM2 = READ_WRITE 0x200 TO 0x27F;
AROM = READ_ONLY 0xC000 TO 0xFFE0;
PLACEMENT
DEFAULT_ROM, ROM_VAR, STRINGS INTO AROM;
DEFAULT_RAM INTO ARAM;
_ZEROPAGE INTO AZRAM;
_OVERLAP INTO ARAM2;
SSTACK INTO ASTACK;
PORTS INTO APORTS;
MISC INTO AMISC;
SPI INTO ASPI;
WDG INTO AWDG;
TIMERA INTO ATIMERA;
TIMERB INTO ATIMERB;
SCI INTO ASCI;
ADC INTO AADC;
END
The compiler and the linker must be set to work accordingly.
The compiler must be aware that the _OVERLAP section is not in the zero page, so that it
cannot use short direct addressing. This is done using the
-Mlx option, where x means that
the local data must be accessed using extended addressing mode. The compiler options, as
set in the
DEFAULT.ENV file, are as follows:
COMPOPTIONS=-Or -Cni -Cc -Mlx
The -Cc option indicates that the constant data (the table of 7-segment patterns) is to be
placed only in ROM.
The linker must also be aware of these choices, by specifying the linking of the
ANSIX.LIB li-
brary and the
START07X.O startup file along with the project files, instead of ANSI.LIB and
START07.O.
Note:The
README.TXT file in the main HICROSS directory summarizes the coordination of
these options.
Once these settings are placed, the project can be built. It is then time to fine-tune the memory
allocation. If all variables were defined without paying any special attention, they would all be
in the
DEFAULT_RAM segment. This segment would then be too big and eat into the stack seg-
ment, while the
_ZEROPAGE segment would not be full enough. To improve the balance, some
variables in the
INTERRUPT.C file have been moved to page zero using the following pragma:
#pragma DATA_SEG SHORT _ZEROPAGE