From 0c014465748fe02967b2cc8e0627bdfe72cfea57 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Tue, 2 Jan 2024 22:17:14 -0800 Subject: [PATCH] PATH: Shave 9 bytes --- README.md | 3 +++ path.s | 45 ++++++++++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index ba49b70..6254fdc 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,9 @@ Example: Notes: * `PATH` can be invoked as lower case (e.g. `path /hd/cmd`) * Commands can be invoked as lower case (e.g. `hello`) +* A relative `PATH` (e.g. `path bin`) only works if an explicit prefix is set. + * Note that if no prefix has been set, or if you run `prefix /`, BASIC.SYSTEM will use the last accessed slot and drive and the `PREFIX` command will report that volume as a prefix even though it is empty. + Sample commands included: * `HELLO` - shows a short message, for testing purposes diff --git a/path.s b/path.s index 5140adb..06c9c4b 100644 --- a/path.s +++ b/path.s @@ -330,7 +330,7 @@ notok: dey ;; Indicate end of command string for BI's parser (if command uses it) dex - stx XLEN + stx xlen ; assigned to `XLEN` later ;; Check to see if path exists. lda #$A ; param length @@ -345,14 +345,11 @@ notok: dey bne compose ; wrong type - try next path directory ;; Tell BASIC.SYSTEM it was handled. - lda #0 - sta XCNUM - sta PBITS - sta PBITS+1 - lda #XRETURN - sta XTRNADDR+1 + ldx #xtrnaddr_len - 1 +: lda xtrnaddr,x + sta XTRNADDR,x + dex + bpl :- ;; MLI/BI trashes part of INBUF (clock driver?), so stash it in upper half. ldx #$7F @@ -374,14 +371,12 @@ notok: dey sta RWREFNUM sta CFREFNUM - lda #cmd_load_addr - sta RWDATA+1 - lda #max_cmd_size - sta RWCOUNT+1 + ;; Assign `RWDATA` and `RWCOUNT` + ldx #rwdata_len - 1 +: lda rwdata,x + sta RWDATA,x + dex + bpl :- lda #READ jsr GOSYSTEM @@ -407,6 +402,22 @@ notok: dey fail_load: rts + +;;; Assigned to `XTRNADDR`, `XLEN`, `XCNUM`, and `PBITS` +xtrnaddr: + .addr XRETURN ; assigned to `XTRNADDR` +xlen: .byte 0 ; assigned to `XLEN` + .byte 0 ; assigned to `XCNUM` + .word 0 ; assigned to `PBITS` + xtrnaddr_len = * - xtrnaddr + + +;;; Assigned to `RWDATA` and `RWCOUNT` +rwdata: + .addr cmd_load_addr ; assigned to `RWDATA` + .word max_cmd_size ; assigned to `RWCOUNT` + rwdata_len = * - rwdata + ;;; ============================================================ execute: