From 60bc009991eb11e5f963f2a579e7c441fa8b1ece Mon Sep 17 00:00:00 2001 From: uz Date: Wed, 9 Dec 2009 12:42:24 +0000 Subject: [PATCH] * Moved the BASIC stub that calls the compiled program into it's own segment named EXEHDR. * Renamed BASICHDR to EXEHDR for the PET-II machines. * Moved the call to CHRCH in front of the code that saves the zero page, since open files are sometimes remembered in the zero page, so we need to close them before we grab a copy. git-svn-id: svn://svn.cc65.org/cc65/trunk@4507 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/c128/crt0.s | 19 +++++++++---------- libsrc/c16/crt0.s | 24 ++++++++++++++---------- libsrc/c64/crt0.s | 24 ++++++++++++++---------- libsrc/cbm510/crt0.s | 2 +- libsrc/cbm610/crt0.s | 2 +- libsrc/pet/crt0.s | 24 ++++++++++++++---------- libsrc/plus4/crt0.s | 25 +++++++++++++++---------- libsrc/vic20/crt0.s | 24 ++++++++++++++---------- src/ld65/cfg/c128.cfg | 3 ++- src/ld65/cfg/c16.cfg | 1 + src/ld65/cfg/c64.cfg | 1 + src/ld65/cfg/cbm510.cfg | 4 ++-- src/ld65/cfg/cbm610.cfg | 6 +++--- src/ld65/cfg/pet.cfg | 1 + src/ld65/cfg/plus4.cfg | 1 + src/ld65/cfg/vic20-32k.cfg | 1 + src/ld65/cfg/vic20.cfg | 1 + 17 files changed, 95 insertions(+), 68 deletions(-) diff --git a/libsrc/c128/crt0.s b/libsrc/c128/crt0.s index a9fd8e6d1..d940e121c 100644 --- a/libsrc/c128/crt0.s +++ b/libsrc/c128/crt0.s @@ -18,17 +18,13 @@ ; ------------------------------------------------------------------------ ; Constants -IRQInd = $2FD ; JMP $0000 - used as indirect IRQ vector +IRQInd = $2FD ; JMP $0000 - used as indirect IRQ vector ; ------------------------------------------------------------------------ -; Place the startup code in a special segment to cope with the quirks of -; c128 banking. - -.segment "STARTUP" - ; BASIC header with a SYS call - .org $1BFF +.segment "EXEHDR" + .word Head ; Load address Head: .word @Next .word .version ; Line number @@ -39,14 +35,17 @@ Head: .word @Next .byte <(((Start / 1) .mod 10) + $30) .byte $00 ; End of BASIC line @Next: .word 0 ; BASIC end marker - .reloc ; ------------------------------------------------------------------------ -; Actual code +; Startup code + +.segment "STARTUP" + +Start: ; Close open files -Start: jsr CLRCH + jsr CLRCH ; Switch to the second charset diff --git a/libsrc/c16/crt0.s b/libsrc/c16/crt0.s index 9ac67f8f3..18d6f7b09 100644 --- a/libsrc/c16/crt0.s +++ b/libsrc/c16/crt0.s @@ -17,12 +17,10 @@ ; ------------------------------------------------------------------------ -; Place the startup code in a special segment. - -.segment "STARTUP" - ; BASIC header with a SYS call +.segment "EXEHDR" + .word Head ; Load address Head: .word @Next .word .version ; Line number @@ -35,18 +33,24 @@ Head: .word @Next @Next: .word 0 ; BASIC end marker ; ------------------------------------------------------------------------ -; Actual code +; Startup code -Start: ldx #zpspace-1 -L1: lda sp,x - sta zpsave,x ; save the zero page locations we need - dex - bpl L1 +.segment "STARTUP" + +Start: ; Close open files jsr CLRCH +; Save the zero page locations we need + + ldx #zpspace-1 +L1: lda sp,x + sta zpsave,x + dex + bpl L1 + ; Switch to second charset lda #14 diff --git a/libsrc/c64/crt0.s b/libsrc/c64/crt0.s index 9f434ecbe..1a35423b5 100644 --- a/libsrc/c64/crt0.s +++ b/libsrc/c64/crt0.s @@ -16,12 +16,10 @@ ; ------------------------------------------------------------------------ -; Place the startup code in a special segment. - -.segment "STARTUP" - ; BASIC header with a SYS call +.segment "EXEHDR" + .word Head ; Load address Head: .word @Next .word .version ; Line number @@ -34,18 +32,24 @@ Head: .word @Next @Next: .word 0 ; BASIC end marker ; ------------------------------------------------------------------------ -; Actual code +; Startup code -Start: ldx #zpspace-1 -L1: lda sp,x - sta zpsave,x ; Save the zero page locations we need - dex - bpl L1 +.segment "STARTUP" + +Start: ; Close open files jsr CLRCH +; Save the zero page locations we need + + ldx #zpspace-1 +L1: lda sp,x + sta zpsave,x + dex + bpl L1 + ; Switch to second charset lda #14 diff --git a/libsrc/cbm510/crt0.s b/libsrc/cbm510/crt0.s index ef2cb8c62..fc8acee74 100644 --- a/libsrc/cbm510/crt0.s +++ b/libsrc/cbm510/crt0.s @@ -46,7 +46,7 @@ ; that is overwritten later. ; -.segment "BASICHDR" +.segment "EXEHDR" .byte $03,$00,$11,$00,$0a,$00,$81,$20,$49,$b2,$30,$20,$a4,$20,$34,$00 .byte $19,$00,$14,$00,$87,$20,$4a,$00,$27,$00,$1e,$00,$97,$20,$32,$35 diff --git a/libsrc/cbm610/crt0.s b/libsrc/cbm610/crt0.s index 5b6bb8b3c..c63bdfdb5 100644 --- a/libsrc/cbm610/crt0.s +++ b/libsrc/cbm610/crt0.s @@ -45,7 +45,7 @@ ; that is overwritten later. ; -.segment "BASICHDR" +.segment "EXEHDR" .byte $03,$00,$11,$00,$0a,$00,$81,$20,$49,$b2,$30,$20,$a4,$20,$34,$00 .byte $19,$00,$14,$00,$87,$20,$4a,$00,$27,$00,$1e,$00,$97,$20,$32,$35 diff --git a/libsrc/pet/crt0.s b/libsrc/pet/crt0.s index 135147d36..496ef3b99 100644 --- a/libsrc/pet/crt0.s +++ b/libsrc/pet/crt0.s @@ -15,12 +15,10 @@ .include "../cbm/cbm.inc" ; ------------------------------------------------------------------------ -; Place the startup code in a special segment. - -.segment "STARTUP" - ; BASIC header with a SYS call +.segment "EXEHDR" + .word Head ; Load address Head: .word @Next .word .version ; Line number @@ -33,18 +31,24 @@ Head: .word @Next @Next: .word 0 ; BASIC end marker ; ------------------------------------------------------------------------ -; Actual code +; Startup code -Start: ldx #zpspace-1 -L1: lda sp,x - sta zpsave,x ; Save the zero page locations we need - dex - bpl L1 +.segment "STARTUP" + +Start: ; Close open files jsr CLRCH +; Save the zero page locations we need + + ldx #zpspace-1 +L1: lda sp,x + sta zpsave,x + dex + bpl L1 + ; Switch to second charset. The routine that is called by BSOUT to switch the ; character set will use FNLEN as temporary storage - YUCK! Since the ; initmainargs routine, which parses the command line for arguments needs this diff --git a/libsrc/plus4/crt0.s b/libsrc/plus4/crt0.s index e5e2fd7bf..41176214e 100644 --- a/libsrc/plus4/crt0.s +++ b/libsrc/plus4/crt0.s @@ -20,10 +20,9 @@ IRQInd = $500 ; JMP $0000 - used as indirect IRQ vector ; ------------------------------------------------------------------------ -; Place the startup code in a special segment to cope with the quirks of -; plus/4 banking. +; BASIC header with a SYS call -.segment "STARTUP" +.segment "EXEHDR" .word Head ; Load address Head: .word @Next @@ -37,22 +36,28 @@ Head: .word @Next @Next: .word 0 ; BASIC end marker ; ------------------------------------------------------------------------ -; Actual code +; Startup code + +.segment "STARTUP" + +Start: -Start: sei ; No interrupts since we're banking out the ROM +; Close open files + + jsr $FFCC ; CLRCH + +; Save the zero page locations we need + + sei ; No interrupts since we're banking out the ROM sta ENABLE_RAM ldx #zpspace-1 L1: lda sp,x - sta zpsave,x ; save the zero page locations we need + sta zpsave,x dex bpl L1 sta ENABLE_ROM cli -; Close open files - - jsr $FFCC ; CLRCH - ; Switch to second charset lda #14 diff --git a/libsrc/vic20/crt0.s b/libsrc/vic20/crt0.s index 559f22dff..1f39ab17e 100644 --- a/libsrc/vic20/crt0.s +++ b/libsrc/vic20/crt0.s @@ -15,12 +15,10 @@ .include "vic20.inc" ; ------------------------------------------------------------------------ -; Place the startup code in a special segment. - -.segment "STARTUP" - ; BASIC header with a SYS call +.segment "EXEHDR" + .word Head ; Load address Head: .word @Next .word .version ; Line number @@ -33,18 +31,24 @@ Head: .word @Next @Next: .word 0 ; BASIC end marker ; ------------------------------------------------------------------------ -; Actual code +; Startup code -Start: ldx #zpspace-1 -L1: lda sp,x - sta zpsave,x ; Save the zero page locations we need - dex - bpl L1 +.segment "STARTUP" + +Start: ; Close open files jsr CLRCH +; Save the zero page locations we need + + ldx #zpspace-1 +L1: lda sp,x + sta zpsave,x + dex + bpl L1 + ; Switch to second charset lda #14 diff --git a/src/ld65/cfg/c128.cfg b/src/ld65/cfg/c128.cfg index 155288713..019e8ea7b 100644 --- a/src/ld65/cfg/c128.cfg +++ b/src/ld65/cfg/c128.cfg @@ -1,8 +1,9 @@ MEMORY { ZP: start = $0002, size = $001A, type = rw, define = yes; - RAM: start = $1Bff, size = $A401, file = %O, define = yes; + RAM: start = $1BFF, size = $A401, file = %O, define = yes; } SEGMENTS { + EXEHDR: load = RAM, type = ro; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; INIT: load = RAM, type = ro, define = yes, optional = yes; diff --git a/src/ld65/cfg/c16.cfg b/src/ld65/cfg/c16.cfg index 0117d34e1..cb01599e5 100644 --- a/src/ld65/cfg/c16.cfg +++ b/src/ld65/cfg/c16.cfg @@ -3,6 +3,7 @@ MEMORY { RAM: start = $0FFF, size = $7001, file = %O; } SEGMENTS { + EXEHDR: load = RAM, type = ro; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; INIT: load = RAM, type = ro, define = yes, optional = yes; diff --git a/src/ld65/cfg/c64.cfg b/src/ld65/cfg/c64.cfg index 425f2a8bc..91809c1ff 100644 --- a/src/ld65/cfg/c64.cfg +++ b/src/ld65/cfg/c64.cfg @@ -3,6 +3,7 @@ MEMORY { RAM: start = $07FF, size = $C801, file = %O, define = yes; } SEGMENTS { + EXEHDR: load = RAM, type = ro; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; INIT: load = RAM, type = ro, define = yes, optional = yes; diff --git a/src/ld65/cfg/cbm510.cfg b/src/ld65/cfg/cbm510.cfg index 5bbd75540..9c9d373f2 100644 --- a/src/ld65/cfg/cbm510.cfg +++ b/src/ld65/cfg/cbm510.cfg @@ -1,5 +1,5 @@ MEMORY { - BASICHDR: start = $0001, size = $0050, fill = yes, fillval = 0, type = rw, file = %O; + HEADER: start = $0001, size = $0050, fill = yes, fillval = 0, type = rw, file = %O; ZP: start = $0051, size = $00AD, fill = yes, fillval = 0, type = rw, file = %O, define = yes; STARTUP: start = $00FE, size = $0102, fill = yes, fillval = 0, file = %O; PAGE2: start = $0200, size = $0100, fill = yes, fillval = 0, file = %O; @@ -9,7 +9,7 @@ MEMORY { VIDRAM: start = $F000, size = $0400, define = yes, file = ""; } SEGMENTS { - BASICHDR: load = BASICHDR, type = rw; + EXEHDR: load = HEADER, type = rw; STARTUP: load = STARTUP, type = rw; PAGE2: load = PAGE2, type = rw; PAGE3: load = PAGE3, type = rw; diff --git a/src/ld65/cfg/cbm610.cfg b/src/ld65/cfg/cbm610.cfg index 5626452a5..79dd77580 100644 --- a/src/ld65/cfg/cbm610.cfg +++ b/src/ld65/cfg/cbm610.cfg @@ -1,13 +1,13 @@ MEMORY { - BASICHDR: start = $0001, size = $0050, type = rw, fill = yes, fillval = 0, file = %O; + HEADER: start = $0001, size = $0050, type = rw, fill = yes, fillval = 0, file = %O; ZP: start = $0051, size = $00AD, type = rw, define = yes, fill = yes, fillval = 0, file = %O; STARTUP: start = $00FE, size = $0102, fill = yes, fillval = 0, file = %O; PAGE2: start = $0200, size = $0100, fill = yes, fillval = 0, file = %O; PAGE3: start = $0300, size = $0100, fill = yes, fillval = 0, file = %O; RAM: start = $0400, size = $FAAE, file = %O; -} +} SEGMENTS { - BASICHDR: load = BASICHDR, type = rw; + EXEHDR: load = HEADER, type = rw; STARTUP: load = STARTUP, type = rw; PAGE2: load = PAGE2, type = rw; PAGE3: load = PAGE3, type = rw; diff --git a/src/ld65/cfg/pet.cfg b/src/ld65/cfg/pet.cfg index 5385b3c98..f95eb42c3 100644 --- a/src/ld65/cfg/pet.cfg +++ b/src/ld65/cfg/pet.cfg @@ -3,6 +3,7 @@ MEMORY { RAM: start = $03FF, size = $7BFF, file = %O; } SEGMENTS { + EXEHDR: load = RAM, type = ro; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; INIT: load = RAM, type = ro, define = yes, optional = yes; diff --git a/src/ld65/cfg/plus4.cfg b/src/ld65/cfg/plus4.cfg index 6c45a63b1..2b5a31457 100644 --- a/src/ld65/cfg/plus4.cfg +++ b/src/ld65/cfg/plus4.cfg @@ -3,6 +3,7 @@ MEMORY { RAM: start = $0FFF, size = $ED01, file = %O; } SEGMENTS { + EXEHDR: load = RAM, type = ro; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; INIT: load = RAM, type = ro, define = yes, optional = yes; diff --git a/src/ld65/cfg/vic20-32k.cfg b/src/ld65/cfg/vic20-32k.cfg index 38152ea8f..aa333c4dc 100644 --- a/src/ld65/cfg/vic20-32k.cfg +++ b/src/ld65/cfg/vic20-32k.cfg @@ -5,6 +5,7 @@ MEMORY { RAM: start = $11FF, size = $6E01, define = yes, file = %O; } SEGMENTS { + EXEHDR: load = RAM, type = ro; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; INIT: load = RAM, type = ro, define = yes, optional = yes; diff --git a/src/ld65/cfg/vic20.cfg b/src/ld65/cfg/vic20.cfg index 11686f124..6ab066aa3 100644 --- a/src/ld65/cfg/vic20.cfg +++ b/src/ld65/cfg/vic20.cfg @@ -3,6 +3,7 @@ MEMORY { RAM: start = $0FFF, size = $0E01, define = yes, file = %O; } SEGMENTS { + EXEHDR: load = RAM, type = ro; STARTUP: load = RAM, type = ro; LOWCODE: load = RAM, type = ro, optional = yes; INIT: load = RAM, type = ro, define = yes, optional = yes; -- 2.39.2