From 280f296952fcabee36ea66088e698846c0d43d9b Mon Sep 17 00:00:00 2001 From: Colin Leroy-Mira Date: Sat, 25 Oct 2025 12:00:17 +0200 Subject: [PATCH] Apple2: mutualize mli filename push (-0 to -18 bytes) --- libsrc/apple2/exec.s | 5 ++--- libsrc/apple2/file_set_info.s | 7 +++---- libsrc/apple2/filename.s | 6 ++++-- libsrc/apple2/mli_file_info.s | 7 +++---- libsrc/apple2/mli_file_info_direct.s | 2 +- libsrc/apple2/open.s | 5 ++--- libsrc/apple2/sysmkdir.s | 5 ++--- libsrc/apple2/sysrename.s | 5 ++--- 8 files changed, 19 insertions(+), 23 deletions(-) diff --git a/libsrc/apple2/exec.s b/libsrc/apple2/exec.s index 38f31ee37..8c52ca400 100644 --- a/libsrc/apple2/exec.s +++ b/libsrc/apple2/exec.s @@ -7,7 +7,7 @@ .export _exec .import mli_file_info_direct .import aux80col - .import pushname, popname, popax, done, _exit + .import pushname_tos, popname, popax, done, _exit .include "zeropage.inc" .include "errno.inc" @@ -28,8 +28,7 @@ _exec: stx ptr4+1 ; Get and push name - jsr popax - jsr pushname + jsr pushname_tos bne oserr jsr mli_file_info_direct diff --git a/libsrc/apple2/file_set_info.s b/libsrc/apple2/file_set_info.s index 4e1e9e541..cfd94f483 100644 --- a/libsrc/apple2/file_set_info.s +++ b/libsrc/apple2/file_set_info.s @@ -6,13 +6,13 @@ ; .export _file_set_type, _file_set_auxtype - .import pushname, popname, mli_file_info_direct + .import pushname_tos, popname, mli_file_info_direct .import popa, popax .include "zeropage.inc" .include "errno.inc" .include "mli.inc" -new_value = ptr2 ; ptr1 is used by pushname +new_value = ptr2 ; ptr1 is used by pushname_tos mod_flag = tmp1 UPDATE_TYPE = $00 @@ -31,8 +31,7 @@ mli_update: sty mod_flag ; Get pathname - jsr popax - jsr pushname + jsr pushname_tos bne oserr ; ProDOS 8 TechRef, 4.4.4: You should use diff --git a/libsrc/apple2/filename.s b/libsrc/apple2/filename.s index f4723ee1f..f8ce06ace 100644 --- a/libsrc/apple2/filename.s +++ b/libsrc/apple2/filename.s @@ -4,13 +4,15 @@ ; File name handling for ProDOS 8 file I/O ; - .export pushname, popname - .import subysp, addysp, decsp1 + .export pushname_tos, pushname, popname + .import popax, subysp, addysp, decsp1 .include "zeropage.inc" .include "apple2.inc" .include "mli.inc" +pushname_tos: + jsr popax pushname: sta ptr1 stx ptr1+1 diff --git a/libsrc/apple2/mli_file_info.s b/libsrc/apple2/mli_file_info.s index 16e01c07f..ff64fb0a4 100644 --- a/libsrc/apple2/mli_file_info.s +++ b/libsrc/apple2/mli_file_info.s @@ -3,7 +3,7 @@ ; .export mli_file_info - .import pushname, popname, mli_file_info_direct + .import pushname_tos, popname, mli_file_info_direct .import popax .include "zeropage.inc" .include "errno.inc" @@ -13,9 +13,8 @@ ; stored as C string in AX at top of stack ; Returns with carry set on error, and sets errno mli_file_info: - ; Get pathname - jsr popax - jsr pushname + ; Get pathname from top of stack + jsr pushname_tos bne oserr jsr mli_file_info_direct diff --git a/libsrc/apple2/mli_file_info_direct.s b/libsrc/apple2/mli_file_info_direct.s index 7fdaa9edf..cf18cada0 100644 --- a/libsrc/apple2/mli_file_info_direct.s +++ b/libsrc/apple2/mli_file_info_direct.s @@ -10,7 +10,7 @@ ; filename stored on top of stack ; Returns with carry set on error, and sets errno mli_file_info_direct: - ; Set pushed name + ; Set pushed name from TOS lda c_sp ldx c_sp+1 sta mliparam + MLI::INFO::PATHNAME diff --git a/libsrc/apple2/open.s b/libsrc/apple2/open.s index 134898211..ec788153e 100644 --- a/libsrc/apple2/open.s +++ b/libsrc/apple2/open.s @@ -9,7 +9,7 @@ .constructor raisefilelevel .destructor closeallfiles, 5 - .import pushname, popname, __dos_type + .import pushname_tos, popname, __dos_type .import iobuf_alloc, iobuf_free .import addysp, incsp4, incaxy, pushax, popax @@ -87,8 +87,7 @@ found: sty tmp2 sta tmp3 ; Get and push name - jsr popax - jsr pushname + jsr pushname_tos bne oserr1 ; Set pushed name diff --git a/libsrc/apple2/sysmkdir.s b/libsrc/apple2/sysmkdir.s index e59421319..1f62d323f 100644 --- a/libsrc/apple2/sysmkdir.s +++ b/libsrc/apple2/sysmkdir.s @@ -5,7 +5,7 @@ ; .export __sysmkdir - .import pushname, popname + .import pushname_tos, popname .import addysp, popax .include "zeropage.inc" @@ -18,8 +18,7 @@ __sysmkdir: jsr addysp ; Get and push name - jsr popax - jsr pushname + jsr pushname_tos bne oserr ; Set pushed name diff --git a/libsrc/apple2/sysrename.s b/libsrc/apple2/sysrename.s index 3e380548f..a0726f4d9 100644 --- a/libsrc/apple2/sysrename.s +++ b/libsrc/apple2/sysrename.s @@ -5,7 +5,7 @@ ; .export __sysrename - .import pushname, popname + .import pushname, pushname_tos, popname .import popax .include "zeropage.inc" @@ -17,8 +17,7 @@ __sysrename: stx ptr2+1 ; Get and push oldname - jsr popax - jsr pushname + jsr pushname_tos bne oserr1 ; Save pushed oldname