From ca70700a0b730ca546c715f159a32d86b5cd0165 Mon Sep 17 00:00:00 2001 From: Greg King Date: Thu, 8 Oct 2015 05:05:48 -0400 Subject: [PATCH] Restored the old C-stack initiation code. I had forgotten that the stack must be put below the CBM overlays. --- cfg/c64-overlay.cfg | 2 +- cfg/c64.cfg | 2 +- libsrc/c64/crt0.s | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cfg/c64-overlay.cfg b/cfg/c64-overlay.cfg index 5d0f611cb..a95c1f6ef 100644 --- a/cfg/c64-overlay.cfg +++ b/cfg/c64-overlay.cfg @@ -14,7 +14,7 @@ MEMORY { 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__; diff --git a/cfg/c64.cfg b/cfg/c64.cfg index e4e275f2e..8fe1c0c6f 100644 --- a/cfg/c64.cfg +++ b/cfg/c64.cfg @@ -11,7 +11,7 @@ MEMORY { 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 { diff --git a/libsrc/c64/crt0.s b/libsrc/c64/crt0.s index 4953d4ade..a846897fe 100644 --- a/libsrc/c64/crt0.s +++ b/libsrc/c64/crt0.s @@ -8,7 +8,8 @@ .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" @@ -105,8 +106,8 @@ L1: lda sp,x ; 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 -- 2.39.5