Table of Contents

Memory layout

This page describes the default memory layout of an XC=BASIC program along with the reserved zero page and other locations.

Default memory configuration

On startup, the XC=BASIC runtime library sets up the following memory configuration:

Area Usage
$0000-$9FFF RAM
$A000-$BFFF RAM
$C000-$CFFF RAM
$D000-$DFFF I/O AREA
$E000-$FFFF KERNAL ROM

Note that BASIC ROM is banked out in order to have a large consecutive RAM area for the XC=BASIC program. The above configuration does not change during the lifetime of the program, except for one case: if you use floats, the BASIC ROM is temporary banked in during the floating point calculations. This doesn't effect the code or data that you keep between $A000 and $BFFF.

Program layout

This is the typical layout of an XC=BASIC program :

AreaContent
$0801-$080CBASIC loader
$080D-$0B7BRuntime library*
$0B7C-$????Code
$????-$????Data
$????-$????Variables

*As of current version. This may change any time

After successful compilation, the exact addresses of the above areas will be displayed on the screen.

The variable area is not included in the assembled binary, but you should note the end of it and make sure you don't overwrite its contents.

Zero page usage

The following zero page locations are reserved by XC=BASIC:

LocationNote
$02-$10Reserved if using FAST variables
$3F-$46Reserved
$61-$6EReserved if using FLOATS
$FB-$FEReserved

Other reserved locations

LocationNote
$0100-$01FFThe stack
$02FE-$02FFReturn address of USR()