Next Previous Contents

3. Memory layout

The default linker script assumes that the BASIC ROM is disabled (or the BASIC cartridge unplugged). This gives a usable memory range from $2E00 - $BC1F. The library startup code examines the current memory configuration, which depends on the size of the installed memory and cartridges present, by inspecting the value in the MEMTOP ($2E5) variable. Then the initial stack pointer, which indicates the upper bound of memory used, is adjusted. The load address of $2E00 was chosen to accommodate having a DOS loaded and a driver that resides in low memory such as the 850 R: handler. You can override this behaviour by creating a custom linker config file.

Special locations:

Text screen

The text screen depends on the installed memory size and cartridges and can be obtained from the SAVMSC variable ($58).

Stack

The C runtime stack is located at MEMTOP and grows downwards, regardless of how your linker config file is setup. This accommodates the different memory configurations of the Atari machines, as well as having a cartridge installed. You can override this behaviour by writing your own crt0.s file and linking it to your program (see also Final note).

Heap

The C heap is located at the end of the program and grows towards the C runtime stack.


Next Previous Contents