Next Previous Contents

3. Memory layout

In the standard setup, cc65 generated programs use the memory from $803 to $95FF, so 35.5 KB of RAM are available.

Special locations:


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


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

While running main() the Language Card bank 2 is enabled for read access. However while running module constructors/destructors the Language Card is disabled.

Enabling the Language Card allows to use it as additional memory for cc65 generated code. However code is never automatically placed there. Rather code needs to be explicitly placed in the Language Card either per file by compiling with --code-name HIGHCODE or per function by enclosing in #pragma code-name (push, "HIGHCODE") and #pragma code-name (pop). In either case the cc65 runtime system takes care of actually moving the code into the Language Card.

The amount of memory available in the Language Card for generated code depends on the chosen linker configuration.

Next Previous Contents