Adjusted current working directory initialization on Apple and Atari.

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.
This commit is contained in:
Oliver Schmidt 2015-10-15 00:15:38 +02:00
parent 0ee9b2e446
commit 76a5a72403
16 changed files with 40 additions and 32 deletions

View 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;

View 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;

View 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;

View 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;

View 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;

View 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;

View 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;

View 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;

View 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;

View 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;

View 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;

View 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;

View 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;

View 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"
@ -29,14 +29,14 @@
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
@ -51,14 +51,14 @@
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

View 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

View File

@ -21,13 +21,13 @@
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