From ec7751332fd72daeb8eb5be811f1e86be9adbc02 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Wed, 15 Jun 2016 23:52:16 +0200 Subject: [PATCH 1/2] Fix exec() for atarixl target. The final part of exec() called 'excexit' and only then restored the stack pointer to its value at program entry. 'excexit' does all cleanup (the same as '_exit()'), which means that on the atarixl target the ROM is banked in again. On big programs the 'SP_save' variable might reside at a high memory address which is no longer accessible after the ROM has been banked in. The change just moves the restoration of the stack pointer before the call to 'excexit'. Another change lets exec.s compile if UCASE_FILENAME is not defined. And some other small cleanups, also in open.s. --- libsrc/atari/exec.s | 20 +++++++++++++------- libsrc/atari/open.s | 3 +-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/libsrc/atari/exec.s b/libsrc/atari/exec.s index 4ae30fdbf..260a772b4 100644 --- a/libsrc/atari/exec.s +++ b/libsrc/atari/exec.s @@ -11,11 +11,9 @@ .import __dos_type .import findfreeiocb .import incsp2 - .import __do_oserror .import excexit ; from crt0.s .import SP_save ; from crt0.s .ifdef UCASE_FILENAME - .importzp tmp3 .import ucase_fn .import addysp .endif @@ -24,7 +22,10 @@ .include "errno.inc" .include "atari.inc" -CMDLINE_BUFFER = $0100 ; put progname + cmdline as one single string there +; area $0100 to $0128 might be in use (e.g. Hias' high speed patch) +CMDLINE_BUFFER = $0129 ; put progname + cmdline as one single string there +; alternatively: +;CMDLINE_BUFFER = $0480 ; put progname + cmdline as one single string there CMDLINE_MAX = 40+3 ; max. length of drive + progname + cmdline .code @@ -85,6 +86,11 @@ copyp: lda (ptr4),y ; programe name too long beq invret +.ifndef UCASE_FILENAME +invret: lda #EINVAL + bne seterr +.endif + ; file name copied, check for args copypd: tya ; put Y into X (index into CMDLINE_BUFFER) @@ -172,11 +178,11 @@ openok: lda #>buf ; here's the point of no return lda tmp4 ; get IOCB index - pha ; and save it ('excexit' calls destructors and they might destroy tmp4) - jsr excexit - pla ldx SP_save - txs ; reset stack pointer + txs ; reset stack pointer to what it was at program entry + pha ; and save it ('excexit' calls destructors and they might destroy tmp4) + jsr excexit ; on atarixl this will enable the ROM again, making all high variables inaccessible + pla tax ; IOCB index in X lda # Date: Thu, 16 Jun 2016 00:47:13 +0200 Subject: [PATCH 2/2] A small rearrangement of instructions in Atari's exec() to let the comments make sense again. --- libsrc/atari/exec.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/atari/exec.s b/libsrc/atari/exec.s index 260a772b4..16062a294 100644 --- a/libsrc/atari/exec.s +++ b/libsrc/atari/exec.s @@ -177,9 +177,9 @@ openok: lda #>buf ; program file appears to be available and good ; here's the point of no return - lda tmp4 ; get IOCB index ldx SP_save txs ; reset stack pointer to what it was at program entry + lda tmp4 ; get IOCB index pha ; and save it ('excexit' calls destructors and they might destroy tmp4) jsr excexit ; on atarixl this will enable the ROM again, making all high variables inaccessible pla