I had forgotten that the stack must be put below the CBM overlays.
ZP: file = "", define = yes, start = $0002, size = $001A;
LOADADDR: file = %O, start = %S - 2, size = $0002;
HEADER: file = %O, define = yes, start = %S, size = $000D;
- RAM: file = %O, start = __HEADER_LAST__, size = __HIMEM__ - __OVERLAYSIZE__ - __STACKSIZE__ - __HEADER_LAST__;
+ RAM: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __OVERLAYSIZE__ - __STACKSIZE__ - __HEADER_LAST__;
MOVE: file = %O, start = __ZPSAVE_LOAD__, size = __HIMEM__ - __INIT_RUN__;
OVL1ADDR: file = "%O.1", start = __HIMEM2__ - __OVERLAYSIZE__, size = $0002;
OVL1: file = "%O.1", start = __HIMEM__ - __OVERLAYSIZE__, size = __OVERLAYSIZE__;
ZP: file = "", define = yes, start = $0002, size = $001A;
LOADADDR: file = %O, start = %S - 2, size = $0002;
HEADER: file = %O, define = yes, start = %S, size = $000D;
- RAM: file = %O, start = __HEADER_LAST__, size = __HIMEM__ - __STACKSIZE__ - __HEADER_LAST__;
+ RAM: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __STACKSIZE__ - __HEADER_LAST__;
MOVE: file = %O, start = __ZPSAVE_LOAD__, size = __HIMEM__ - __INIT_RUN__;
}
SEGMENTS {
.import initlib, donelib
.import moveinit, zerobss, callmain
.import BSOUT
- .import __HIMEM__ ; from configure file
+ .import __RAM_START__, __RAM_SIZE__ ; Linker generated
+ .import __STACKSIZE__ ; from configure file
.importzp ST
.include "zeropage.inc"
; Set up the stack.
- lda #<__HIMEM__
- ldx #>__HIMEM__
+ lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
+ ldx #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
sta sp
stx sp+1 ; Set argument stack ptr