]> git.sur5r.net Git - cc65/commitdiff
Adjusted current working directory initialization on Apple and Atari.
authorOliver Schmidt <ol.sc@web.de>
Wed, 14 Oct 2015 22:15:38 +0000 (00:15 +0200)
committerOliver Schmidt <ol.sc@web.de>
Wed, 14 Oct 2015 22:15:38 +0000 (00:15 +0200)
Moving __cwd from BSS into INITBSS does of course ;-) not only impact the CBM targets but all targets with disk I/O support.

Note: Code using `__cwd-1` may trigger an ld65 range error because __cwd may end up at the very begining of a segment. As far as I see this is an ld65 bug which I'm not try to fix - at least here.

16 files changed:
cfg/apple2-overlay.cfg
cfg/apple2-system.cfg
cfg/apple2.cfg
cfg/apple2enh-overlay.cfg
cfg/apple2enh-system.cfg
cfg/apple2enh.cfg
cfg/atari-cart.cfg
cfg/atari-cassette.cfg
cfg/atari-overlay.cfg
cfg/atari.cfg
cfg/atarixl-largehimem.cfg
cfg/atarixl-overlay.cfg
cfg/atarixl.cfg
libsrc/apple2/crt0.s
libsrc/apple2/initcwd.s
libsrc/atari/initcwd.s

index d0b34692f4d17905e088c804a41393d9844c532c..244e4582f827a70be5806fc2a1e041c5a706da1a 100644 (file)
@@ -18,7 +18,7 @@ SYMBOLS {
     __STACKSIZE__:   type = weak, value = $0800; # 2k stack
     __OVERLAYSIZE__: type = weak, value = $1000; # 4k overlay
     __LOADADDR__:    type = weak, value = __STARTUP_RUN__;
-    __LOADSIZE__:    type = weak, value = __ZPSAVE_RUN__ - __STARTUP_RUN__ +
+    __LOADSIZE__:    type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ +
                                           __MOVE_LAST__  - __MOVE_START__;
 }
 MEMORY {
@@ -45,7 +45,7 @@ SEGMENTS {
     CODE:     load = RAM,             type = ro;
     RODATA:   load = RAM,             type = ro;
     DATA:     load = RAM,             type = rw;
-    ZPSAVE:   load = RAM,             type = bss, define = yes;
+    INITBSS:  load = RAM,             type = bss, define = yes;
     BSS:      load = RAM,             type = bss, define = yes;
     INIT:     load = MOVE, run = RAM, type = ro,  define = yes, optional = yes;
     LC:       load = MOVE, run = LC,  type = ro,                optional = yes;
index 33ab04f5e30920b0ae3c723c093aca66dd269e73..f07208e4545b79c00cac17ef541332ed5f56c548 100644 (file)
@@ -5,7 +5,7 @@ SYMBOLS {
     __LCSIZE__:    type = weak, value = $0C00; # Rest of bank two
     __STACKSIZE__: type = weak, value = $0800; # 2k stack
     __LOADADDR__:  type = weak, value = __STARTUP_RUN__;
-    __LOADSIZE__:  type = weak, value = __ZPSAVE_RUN__ - __STARTUP_RUN__ +
+    __LOADSIZE__:  type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ +
                                         __MOVE_LAST__  - __MOVE_START__;
 }
 MEMORY {
@@ -21,7 +21,7 @@ SEGMENTS {
     CODE:     load = RAM,             type = ro;
     RODATA:   load = RAM,             type = ro;
     DATA:     load = RAM,             type = rw;
-    ZPSAVE:   load = RAM,             type = bss, define   = yes;
+    INITBSS:  load = RAM,             type = bss, define   = yes;
     BSS:      load = RAM,             type = bss, define   = yes;
     INIT:     load = MOVE, run = RAM, type = ro,  define   = yes, optional = yes;
     LC:       load = MOVE, run = LC,  type = ro,                  optional = yes;
index 5673302d10292d2567ed8b259c9ffed610790aab..27eb706c486e143d2ffca0c25c5d2185b91bc5c8 100644 (file)
@@ -10,7 +10,7 @@ SYMBOLS {
     __LCSIZE__:    type = weak, value = $0C00; # Rest of bank two
     __STACKSIZE__: type = weak, value = $0800; # 2k stack
     __LOADADDR__:  type = weak, value = __STARTUP_RUN__;
-    __LOADSIZE__:  type = weak, value = __ZPSAVE_RUN__ - __STARTUP_RUN__ +
+    __LOADSIZE__:  type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ +
                                         __MOVE_LAST__  - __MOVE_START__;
 }
 MEMORY {
@@ -28,7 +28,7 @@ SEGMENTS {
     CODE:     load = RAM,             type = ro;
     RODATA:   load = RAM,             type = ro;
     DATA:     load = RAM,             type = rw;
-    ZPSAVE:   load = RAM,             type = bss, define   = yes;
+    INITBSS:  load = RAM,             type = bss, define   = yes;
     BSS:      load = RAM,             type = bss, define   = yes;
     INIT:     load = MOVE, run = RAM, type = ro,  define   = yes, optional = yes;
     LC:       load = MOVE, run = LC,  type = ro,                  optional = yes;
index d0b34692f4d17905e088c804a41393d9844c532c..244e4582f827a70be5806fc2a1e041c5a706da1a 100644 (file)
@@ -18,7 +18,7 @@ SYMBOLS {
     __STACKSIZE__:   type = weak, value = $0800; # 2k stack
     __OVERLAYSIZE__: type = weak, value = $1000; # 4k overlay
     __LOADADDR__:    type = weak, value = __STARTUP_RUN__;
-    __LOADSIZE__:    type = weak, value = __ZPSAVE_RUN__ - __STARTUP_RUN__ +
+    __LOADSIZE__:    type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ +
                                           __MOVE_LAST__  - __MOVE_START__;
 }
 MEMORY {
@@ -45,7 +45,7 @@ SEGMENTS {
     CODE:     load = RAM,             type = ro;
     RODATA:   load = RAM,             type = ro;
     DATA:     load = RAM,             type = rw;
-    ZPSAVE:   load = RAM,             type = bss, define = yes;
+    INITBSS:  load = RAM,             type = bss, define = yes;
     BSS:      load = RAM,             type = bss, define = yes;
     INIT:     load = MOVE, run = RAM, type = ro,  define = yes, optional = yes;
     LC:       load = MOVE, run = LC,  type = ro,                optional = yes;
index 33ab04f5e30920b0ae3c723c093aca66dd269e73..f07208e4545b79c00cac17ef541332ed5f56c548 100644 (file)
@@ -5,7 +5,7 @@ SYMBOLS {
     __LCSIZE__:    type = weak, value = $0C00; # Rest of bank two
     __STACKSIZE__: type = weak, value = $0800; # 2k stack
     __LOADADDR__:  type = weak, value = __STARTUP_RUN__;
-    __LOADSIZE__:  type = weak, value = __ZPSAVE_RUN__ - __STARTUP_RUN__ +
+    __LOADSIZE__:  type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ +
                                         __MOVE_LAST__  - __MOVE_START__;
 }
 MEMORY {
@@ -21,7 +21,7 @@ SEGMENTS {
     CODE:     load = RAM,             type = ro;
     RODATA:   load = RAM,             type = ro;
     DATA:     load = RAM,             type = rw;
-    ZPSAVE:   load = RAM,             type = bss, define   = yes;
+    INITBSS:  load = RAM,             type = bss, define   = yes;
     BSS:      load = RAM,             type = bss, define   = yes;
     INIT:     load = MOVE, run = RAM, type = ro,  define   = yes, optional = yes;
     LC:       load = MOVE, run = LC,  type = ro,                  optional = yes;
index 5673302d10292d2567ed8b259c9ffed610790aab..27eb706c486e143d2ffca0c25c5d2185b91bc5c8 100644 (file)
@@ -10,7 +10,7 @@ SYMBOLS {
     __LCSIZE__:    type = weak, value = $0C00; # Rest of bank two
     __STACKSIZE__: type = weak, value = $0800; # 2k stack
     __LOADADDR__:  type = weak, value = __STARTUP_RUN__;
-    __LOADSIZE__:  type = weak, value = __ZPSAVE_RUN__ - __STARTUP_RUN__ +
+    __LOADSIZE__:  type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ +
                                         __MOVE_LAST__  - __MOVE_START__;
 }
 MEMORY {
@@ -28,7 +28,7 @@ SEGMENTS {
     CODE:     load = RAM,             type = ro;
     RODATA:   load = RAM,             type = ro;
     DATA:     load = RAM,             type = rw;
-    ZPSAVE:   load = RAM,             type = bss, define   = yes;
+    INITBSS:  load = RAM,             type = bss, define   = yes;
     BSS:      load = RAM,             type = bss, define   = yes;
     INIT:     load = MOVE, run = RAM, type = ro,  define   = yes, optional = yes;
     LC:       load = MOVE, run = LC,  type = ro,                  optional = yes;
index db9486a9fc7d0d6a3d215bcef712766fe310b05e..58457c60678b07a64deb0413bd11481926bb287d 100644 (file)
@@ -22,6 +22,7 @@ SEGMENTS {
     CODE:      load = ROM,            type = ro,  define = yes;
     RODATA:    load = ROM,            type = ro,                optional = yes;
     DATA:      load = ROM, run = RAM, type = rw,  define = yes, optional = yes;
+    INITBSS:   load = RAM,            type = bss,               optional = yes;
     BSS:       load = RAM,            type = bss, define = yes, optional = yes;
     CARTHDR:   load = CARTID,         type = ro;
     ZEROPAGE:  load = ZP,             type = zp,                optional = yes;
index 2116aecd0d496a9ad1a70ed6579e8ebda6ec8ac8..80b5c695f12976a6a8f26e6d1bc5331295a6cb8c 100644 (file)
@@ -19,6 +19,7 @@ SEGMENTS {
     CODE:      load = RAM, type = ro,  define = yes;
     RODATA:    load = RAM, type = ro,                optional = yes;
     DATA:      load = RAM, type = rw,                optional = yes;
+    INITBSS:   load = RAM, type = bss,               optional = yes;
     BSS:       load = RAM, type = bss, define = yes, optional = yes;
     ZEROPAGE:  load = ZP,  type = zp,                optional = yes;
     EXTZP:     load = ZP,  type = zp,                optional = yes;
index 1d339b2081dc7f1b32652d898abf0c75b752de1c..b3abad988e4a1905d37866c2f4c4fe96f7d8c3b2 100644 (file)
@@ -49,6 +49,7 @@ SEGMENTS {
     CODE:      load = RAM,        type = ro,  define = yes;
     RODATA:    load = RAM,        type = ro;
     DATA:      load = RAM,        type = rw;
+    INITBSS:   load = RAM,        type = bss,               optional = yes;
     BSS:       load = RAM,        type = bss, define = yes;
     ZEROPAGE:  load = ZP,         type = zp;
     EXTZP:     load = ZP,         type = zp,                optional = yes;
index dce593f0532d09ae5a59a78a037107ea1b52130e..97b289d7e7a27ce5200732e394c48f9e4e752d42 100644 (file)
@@ -37,6 +37,7 @@ SEGMENTS {
     CODE:      load = RAM,        type = ro,  define = yes;
     RODATA:    load = RAM,        type = ro;
     DATA:      load = RAM,        type = rw;
+    INITBSS:   load = RAM,        type = bss,               optional = yes;
     BSS:       load = RAM,        type = bss, define = yes;
     ZEROPAGE:  load = ZP,         type = zp;
     EXTZP:     load = ZP,         type = zp,                optional = yes;
index 01fc76a2680c39dbef65433e70c13cbbfe444e04..f96096995aaefdea196077744b14bd54aa5f6280 100644 (file)
@@ -70,6 +70,7 @@ SEGMENTS {
     CODE:        load = RAM,                          type = ro,  define = yes;
     RODATA:      load = RAM,                          type = ro;
     DATA:        load = RAM,                          type = rw;
+    INITBSS:     load = RAM,                          type = bss,               optional = yes;
     BSS:         load = RAM,                          type = bss, define = yes;
     ZEROPAGE:    load = ZP,                           type = zp;
     EXTZP:       load = ZP,                           type = zp,                optional = yes;
index 68d0f524e07622f3bec178aea49228af7ecd9dee..7356fc03e0487bad3fde2224c54e92ec850d6293 100644 (file)
@@ -82,6 +82,7 @@ SEGMENTS {
     CODE:        load = RAM,                           type = ro,  define = yes;
     RODATA:      load = RAM,                           type = ro;
     DATA:        load = RAM,                           type = rw;
+    INITBSS:     load = RAM,                           type = bss,               optional = yes;
     BSS:         load = RAM,                           type = bss, define = yes;
     ZEROPAGE:    load = ZP,                            type = zp;
     EXTZP:       load = ZP,                            type = zp,                optional = yes;
index aad3ce613e692e07a45bc3965845c291df6b97f1..84992a205fd98995c69cc64cfd0754d0298af575 100644 (file)
@@ -68,6 +68,7 @@ SEGMENTS {
     CODE:        load = RAM,                           type = ro,  define = yes;
     RODATA:      load = RAM,                           type = ro;
     DATA:        load = RAM,                           type = rw;
+    INITBSS:     load = RAM,                           type = bss,               optional = yes;
     BSS:         load = RAM,                           type = bss, define = yes;
     ZEROPAGE:    load = ZP,                            type = zp;
     EXTZP:       load = ZP,                            type = zp,                optional = yes;
index 445039b1ec04a32c17ea49e7cdc0de36a4ef0d52..f061b212be71f58ab4d0712924103ccf37a691e4 100644 (file)
@@ -11,7 +11,7 @@
         .import         callmain
         .import         __LC_START__, __LC_LAST__       ; Linker generated
         .import         __INIT_RUN__, __INIT_SIZE__     ; Linker generated
-        .import         __ZPSAVE_RUN__                  ; Linker generated
+        .import         __INITBSS_RUN__                 ; Linker generated
 
         .include        "zeropage.inc"
         .include        "apple2.inc"
         bit     $C081
 
         ; Set the source start address.
-        lda     #<(__ZPSAVE_RUN__ + __INIT_SIZE__)
-        ldy     #>(__ZPSAVE_RUN__ + __INIT_SIZE__)
+        lda     #<(__INITBSS_RUN__ + __INIT_SIZE__)
+        ldy     #>(__INITBSS_RUN__ + __INIT_SIZE__)
         sta     $9B
         sty     $9C
 
         ; Set the source last address.
-        lda     #<(__ZPSAVE_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
-        ldy     #>(__ZPSAVE_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
+        lda     #<(__INITBSS_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
+        ldy     #>(__INITBSS_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
         sta     $96
         sty     $97
 
         jsr     $D39A           ; BLTU2
 
         ; Set the source start address.
-        lda     #<__ZPSAVE_RUN__
-        ldy     #>__ZPSAVE_RUN__
+        lda     #<__INITBSS_RUN__
+        ldy     #>__INITBSS_RUN__
         sta     $9B
         sty     $9C
 
         ; Set the source last address.
-        lda     #<(__ZPSAVE_RUN__ + __INIT_SIZE__)
-        ldy     #>(__ZPSAVE_RUN__ + __INIT_SIZE__)
+        lda     #<(__INITBSS_RUN__ + __INIT_SIZE__)
+        ldy     #>(__INITBSS_RUN__ + __INIT_SIZE__)
         sta     $96
         sty     $97
 
@@ -201,7 +201,7 @@ q_param:.byte   $04             ; param_count
         ; Final jump when we're done
 done:   jmp     DOSWARM         ; Potentially patched at runtime
 
-        .segment        "ZPSAVE"
+        .segment        "INITBSS"
 
 zpsave: .res    zpspace
 
index 044076e3ff4143b63e7f7dabd76037695e016343..7af29c75e78c2ac7902dffdd0045a87bd3734bc7 100644 (file)
@@ -21,20 +21,21 @@ initcwd:
         jsr     callmli
 
         ; Check for null prefix
-        lda     __cwd
+        ldx     __cwd
         beq     done
 
         ; Remove length byte and trailing slash
-        sta     tmp1
-        ldx     #$01
-:       lda     __cwd,x
-        sta     __cwd - 1,x
+        dex
+        stx     tmp1
+        ldx     #$00
+:       lda     __cwd + 1,x
+        sta     __cwd,x
         inx
         cpx     tmp1
         bcc     :-
 
         ; Add terminating zero
         lda     #$00
-        sta     __cwd - 1,x
+        sta     __cwd,x
         
 done:   rts
index 074b9476fdccc2c8acfded7bd43cc354d97ba755..c292e72c390bad8dfdbcc252b4d37e5a435b633a 100644 (file)
         sta     ICBLH,x
         jsr     CIOV
         bmi     oserr
-        ldx     #0              ; ATEOL -> \0
-:       lda     __cwd,x
-        inx
+        ldx     #$FF            ; ATEOL -> \0
+:       inx
+        lda     __cwd,x
         cmp     #ATEOL
         bne     :-
         lda     #0
-        sta     __cwd-1,x
+        sta     __cwd,x
 oserr:  rts
 
 .endproc