Next Previous Contents

3. Memory layout

In the standard setup, cc65 generated programs use the memory from $803 to $95FF, so 35.5KB of RAM are available. While running main() the Language Card bank 2 is enabled for read access. However while running module constructors/destructors the Language Card is disabled.

Special locations:

Stack

The C runtime stack is located at HIMEM and grows downwards, regardless of how your linker config file is setup.

Heap

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

Enabling the Language Card allows to use it as additional memory for executable code. Actually doing so requires either to compile code with the option --code-name HIGHCODE or to use #pragma codeseg ("HIGHCODE").

The amount of memory available in the Language Card for executable code depends on the chosen program environment. A plain vanilla ProDOS 8 doesn't actually use the Language Card bank 2 memory from $D400 to $DFFF. Therefore the builtin linker configuration defines these 3KB as LC memory area for executable code.

A plain vanilla DOS 3.3 doesn't make use of the Language Card at all. So you can change

    LC: start = $D400, size = $0C00, define = yes;

to

    LC: start = $D000, size = $3000, define = yes;

in the linker configuration to define the whole 12KB Language Card address space as memory area for executable code.


Next Previous Contents