312/317
10 - Second Application: a Sailing Computer
10.6 MEMORY ALLOCATION AND COMPILE AND LINK OPTIONS
The whole program make extensive use of floating point arithmetic. It is thus a memory eater.
The ROM section does not represent a problem, provided a device with a sufficient ROM size
is chosen. Here, a size of 16 Kbytes is necessary.
The RAM allocation is a little bit trickier. The ST7 has two direct addressing modes: short and
extended. The mode must be chosen at compile time, while the actual memory allocation is
done at link time. This means you have to proceed by trial and error, until the proper section
arrangement has been found.
The ST72311J4 used here has its addressable space divided into the following areas:
The position of the stack is fixed, with a start position (top) at 0x1FF. Since the stack does not
need the full 256-byte area, some of it may be allocated for variables. The arrangement used
here is to put the DEFAULT_RAM section from 0x100 to 0x18F, overstepping the stack area
a little bit. The _OVERLAP section is set at 0x200. The _ZEROPAGE section can only be set
below 0x100. This is fully detailed in the link parameter file below:
SECTIONS
APORTS = READ_WRITE 0x00 TO 0x17;
AMISC = READ_WRITE 0x20 TO 0x20;
ASPI = READ_WRITE 0x21 TO 0x23;
AWDG = READ_WRITE 0x2A TO 0x2B;
ATIMERA = READ_WRITE 0x31 TO 0x3F;
ATIMERB = READ_WRITE 0x41 TO 0x4F;
ASCI = READ_WRITE 0x50 TO 0x57;
AADC = READ_WRITE 0x70 TO 0x71;
AZRAM = READ_WRITE 0x80 TO 0xFF;
ARAM = READ_WRITE 0x100 TO 0x19F;
ASTACK = READ_WRITE 0x1A0 TO 0x1FF;
Object From To Access
Hardware registers (peripherals) 0 0x7F Read-Write
Short addressing mode RAM 0x80 0xFF Read-Write
Stack area, some of which may be used as
extended addressing RAM
0x100 0x1FF Read-Write
Extended addressing RAM 0x200 0x27F Read-Write
No addressable object in this area. 0x280 0xBFFF None
ROM 0xC000 0xFFDF Read only
Vectors 0xFFE0 0xFFFF Read only