]> git.sur5r.net Git - cc65/commitdiff
Update from Oliver Schmidt
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 19 Apr 2005 14:28:15 +0000 (14:28 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 19 Apr 2005 14:28:15 +0000 (14:28 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@3470 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/apple2/initcwd.s

index c17e081e3096b72f0a4fcab52da86abbb4892c17..77aa1442f06999eb8810f5c0e9b9982069d4256d 100644 (file)
@@ -4,16 +4,21 @@
 
         .export         initcwd
         .import                __cwd
+        .import                subysp, addysp
 
         .include       "zeropage.inc"
         .include        "mli.inc"
 
-        .segment        "INIT"
-        
+        .segment       "INIT"
+
 initcwd:
-        ; Use imported buffer
-        lda    #<__cwd
-        ldx    #>__cwd
+        ; 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
         sta     mliparam + MLI::PREFIX::PATHNAME
         stx     mliparam + MLI::PREFIX::PATHNAME+1
 
@@ -21,19 +26,24 @@ initcwd:
         lda     #GET_PREFIX_CALL
         ldx     #PREFIX_COUNT
         jsr     callmli
+        bcs    done
 
-        ; Check length byte
-        ldx    __cwd
+        ; Check for null prefix
+        ldy    #$00
+        lda    (sp),y
         beq    done
 
-        ; Replace trailing slash with zero
-        sta    __cwd,x         ; A = 0
-
-        ; Remove length byte
-        tax
-:       inx
-        lda    __cwd,x
-        sta    __cwd-1,x
+        ; 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    :-
 
-done:   rts
+        ; Cleanup stack
+done:   ldy    #1 + 64+1       ; Length byte + max pathname length+trailing slash
+        jmp     addysp
+