]> git.sur5r.net Git - cc65/commitdiff
Update by Oliver Schmidt
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 29 May 2006 16:27:39 +0000 (16:27 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 29 May 2006 16:27:39 +0000 (16:27 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@3742 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/apple2/initcwd.s
libsrc/apple2/syschdir.s

index 77aa1442f06999eb8810f5c0e9b9982069d4256d..6ed914ca63e7582292ab35dce991ef027512b467 100644 (file)
@@ -4,21 +4,14 @@
 
         .export         initcwd
         .import                __cwd
-        .import                subysp, addysp
 
         .include       "zeropage.inc"
         .include        "mli.inc"
 
-        .segment       "INIT"
-
 initcwd:
-        ; Alloc prefix buffer
-        ldy    #1 + 64+1       ; Length byte + max pathname length+trailing slash
-        jsr    subysp
-
-        ; Use allocated prefix buffer
-        lda    sp
-        ldx    sp+1
+        ; Set static prefix buffer
+        lda    #<__cwd
+        ldx    #>__cwd
         sta     mliparam + MLI::PREFIX::PATHNAME
         stx     mliparam + MLI::PREFIX::PATHNAME+1
 
@@ -26,24 +19,22 @@ initcwd:
         lda     #GET_PREFIX_CALL
         ldx     #PREFIX_COUNT
         jsr     callmli
-        bcs    done
 
         ; Check for null prefix
-        ldy    #$00
-        lda    (sp),y
-        beq    done
-
-        ; Set current working directory
-        ; - omit trailing slash and length byte
-        ; - terminating zero already in place
-        tay
-        dey
-:       lda    (sp),y
-        sta    __cwd-1,y
-        dey
-        bne    :-
-
-        ; Cleanup stack
-done:   ldy    #1 + 64+1       ; Length byte + max pathname length+trailing slash
-        jmp     addysp
-
+       lda     __cwd
+       beq     done
+
+       ; Remove length byte and trailing slash
+       sta     tmp1
+       ldx     #$01
+:      lda     __cwd,x
+       sta     __cwd - 1,x
+       inx
+       cpx     tmp1
+       bcc     :-
+
+       ; Add terminating zero
+       lda     #$00
+       sta     __cwd - 1,x
+       
+done:  rts
index 48bbc2eed60e30f3f7a538418caa4d7df87de273..7eb67e1abd895fd975394941f85025bcb3ccfb69 100644 (file)
@@ -6,7 +6,7 @@
 
         .export         __syschdir
         .import                pushname, popname
-       .import         __cwd
+       .import         initcwd
 
        .include        "zeropage.inc"
        .include        "mli.inc"
@@ -28,12 +28,8 @@ __syschdir:
         jsr    callmli
        bcs     cleanup
 
-       ldy     #$01
-:      lda     (sp),y
-       sta     __cwd-1,y
-       beq     cleanup
-       iny
-       bne     :-              ; Branch always
+       ; Update current working directory
+       jsr     initcwd         ; Returns with A = 0
 
         ; Cleanup name
 cleanup:jsr    popname         ; Preserves A