From 33c1e82bda1f83ee9c7d4b1e61bece0fc06d32a8 Mon Sep 17 00:00:00 2001 From: cuz Date: Sun, 26 May 2002 09:09:10 +0000 Subject: [PATCH] Move zp space out of crt0.s git-svn-id: svn://svn.cc65.org/cc65/trunk@1291 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/apple2/crt0.s | 37 ++++--------------------------------- libsrc/atari/crt0.s | 35 +++-------------------------------- libsrc/c128/crt0.s | 26 +------------------------- libsrc/c64/crt0.s | 27 +-------------------------- libsrc/dbg/dbgsupp.s | 9 ++++++--- libsrc/pet/crt0.s | 29 ++--------------------------- libsrc/plus4/crt0.s | 29 ++--------------------------- 7 files changed, 19 insertions(+), 173 deletions(-) diff --git a/libsrc/apple2/crt0.s b/libsrc/apple2/crt0.s index f7ef6f39e..d51c282a2 100644 --- a/libsrc/apple2/crt0.s +++ b/libsrc/apple2/crt0.s @@ -9,43 +9,14 @@ .import zerobss, push0 .import _main - .include "apple2.inc" + .include "zeropage.inc" + .include "apple2.inc" ; ------------------------------------------------------------------------ -; Define and export the ZP variables for the C64 runtime - - .exportzp sp, sreg, regsave - .exportzp ptr1, ptr2, ptr3, ptr4 - .exportzp tmp1, tmp2, tmp3, tmp4 - .exportzp regbank, zpspace - -; These zero page entries overlap with the sweet-16 registers in -; the standard apple2 linker config. They must be changed if sweet-16 -; is to be supported - -.zeropage - -zpstart = * -sp: .res 2 ; Stack pointer -sreg: .res 2 ; Secondary register/high 16 bit for longs -regsave: .res 2 ; slot to save/restore (E)AX into -ptr1: .res 2 -ptr2: .res 2 -ptr3: .res 2 -ptr4: .res 2 -tmp1: .res 1 -tmp2: .res 1 -tmp3: .res 1 -tmp4: .res 1 -regbank: .res 6 ; 6 byte register bank - -zpspace = * - zpstart ; Zero page space allocated +; Actual code .code -; ------------------------------------------------------------------------ -; Actual code - ldx #zpspace-1 L1: lda sp,x sta zpsave,x ; Save the zero page locations we need @@ -90,7 +61,7 @@ L1: lda sp,x ; Call module destructors. This is also the _exit entry. _exit: jsr donelib - + ; Restore system stuff lda #$ff ; Reset text mode diff --git a/libsrc/atari/crt0.s b/libsrc/atari/crt0.s index 3c5091f4a..95e5cac0e 100644 --- a/libsrc/atari/crt0.s +++ b/libsrc/atari/crt0.s @@ -18,39 +18,10 @@ .import _main,__filetab,getfd .import __CODE_LOAD__, __BSS_LOAD__ + .include "zeropage.inc" .include "atari.inc" .include "_file.inc" -; ------------------------------------------------------------------------ -; Define and export the ZP variables for the runtime - - .exportzp sp, sreg, regsave - .exportzp ptr1, ptr2, ptr3, ptr4 - .exportzp tmp1, tmp2, tmp3, tmp4 - .exportzp fntemp, regbank, zpspace - - -.zeropage - -zpstart = * -sp: .res 2 ; Stack pointer -sreg: .res 2 ; Secondary register/high 16 bit for longs -regsave: .res 2 ; slot to save/restore (E)AX into -ptr1: .res 2 -ptr2: .res 2 -ptr3: .res 2 -ptr4: .res 2 -tmp1: .res 1 -tmp2: .res 1 -tmp3: .res 1 -tmp4: .res 1 -fntemp: .res 2 ; Pointer to file name -regbank: .res 6 ; 6 byte register bank - -zpspace = * - zpstart ; Zero page space allocated - -.code - ; ------------------------------------------------------------------------ ; EXE header @@ -58,12 +29,12 @@ zpspace = * - zpstart ; Zero page space allocated .word $FFFF .word __CODE_LOAD__ .word __BSS_LOAD__ - 1 - .code - .reloc ; ------------------------------------------------------------------------ ; Actual code +.code + rts ; fix for SpartaDOS / OS/A+ ; they first call the entry point from AUTOSTRT and ; then the load addess (this rts here). diff --git a/libsrc/c128/crt0.s b/libsrc/c128/crt0.s index 4db5e618c..b58550e45 100644 --- a/libsrc/c128/crt0.s +++ b/libsrc/c128/crt0.s @@ -12,6 +12,7 @@ .import __IRQFUNC_TABLE__, __IRQFUNC_COUNT__ .import __RAM_START__, __RAM_SIZE__ + .include "zeropage.inc" .include "c128.inc" .include "../cbm/cbm.inc" @@ -21,31 +22,6 @@ IRQInd = $2FD ; JMP $0000 - used as indirect IRQ vector ; ------------------------------------------------------------------------ -; Define and export the ZP variables for the C64 runtime - - .exportzp sp, sreg, regsave - .exportzp ptr1, ptr2, ptr3, ptr4 - .exportzp tmp1, tmp2, tmp3, tmp4 - .exportzp regbank, zpspace - -.zeropage - -zpstart = * -sp: .res 2 ; Stack pointer -sreg: .res 2 ; Secondary register/high 16 bit for longs -regsave: .res 2 ; slot to save/restore (E)AX into -ptr1: .res 2 -ptr2: .res 2 -ptr3: .res 2 -ptr4: .res 2 -tmp1: .res 1 -tmp2: .res 1 -tmp3: .res 1 -tmp4: .res 1 -regbank: .res 6 ; 6 byte register bank - -zpspace = * - zpstart ; Zero page space allocated - ; Place the startup code in a special segment to cope with the quirks of ; c128 banking. Do also create an empty segment named "NMI" to avoid ; warnings if the rs232 routines are not used. diff --git a/libsrc/c64/crt0.s b/libsrc/c64/crt0.s index 397e51bcf..770297372 100644 --- a/libsrc/c64/crt0.s +++ b/libsrc/c64/crt0.s @@ -10,35 +10,10 @@ .import _main .import __RAM_START__, __RAM_SIZE__ ; Linker generated + .include "zeropage.inc" .include "c64.inc" .include "../cbm/cbm.inc" -; ------------------------------------------------------------------------ -; Define and export the ZP variables for the C64 runtime - - .exportzp sp, sreg, regsave - .exportzp ptr1, ptr2, ptr3, ptr4 - .exportzp tmp1, tmp2, tmp3, tmp4 - .exportzp regbank, zpspace - -.zeropage - -zpstart = * -sp: .res 2 ; Stack pointer -sreg: .res 2 ; Secondary register/high 16 bit for longs -regsave: .res 2 ; slot to save/restore (E)AX into -ptr1: .res 2 -ptr2: .res 2 -ptr3: .res 2 -ptr4: .res 2 -tmp1: .res 1 -tmp2: .res 1 -tmp3: .res 1 -tmp4: .res 1 -regbank: .res 6 ; 6 byte register bank - -zpspace = * - zpstart ; Zero page space allocated - .code ; ------------------------------------------------------------------------ diff --git a/libsrc/dbg/dbgsupp.s b/libsrc/dbg/dbgsupp.s index 64ec3c861..5ab0f5863 100644 --- a/libsrc/dbg/dbgsupp.s +++ b/libsrc/dbg/dbgsupp.s @@ -9,7 +9,10 @@ .import popax, return0, _DbgEntry, _set_brk, _end_brk .import _DbgBreaks .import _brk_pc - .importzp sp, sreg, ptr1, tmp1, zpspace + .import __ZP_START__ ; Linker generated + + .include "zeropage.inc" + ; C callable function, will install the debugger @@ -60,7 +63,7 @@ DbgStack: CTemp: _DbgCS: .res 2 ; sp _DbgHI: .res 2 ; sreg - .res 22 ; Other stuff + .res (zpspace-4) ; Other stuff _DbgSP: .res 1 retsav: .res 2 ; Save buffer for return address @@ -71,7 +74,7 @@ retsav: .res 2 ; Save buffer for return address DbgSwapZP: ldy #zpspace-1 Swap1: ldx CTemp,y - lda sp,y ; ###### + lda <__ZP_START__,y sta CTemp,y txa sta sp,y diff --git a/libsrc/pet/crt0.s b/libsrc/pet/crt0.s index 5d4ac7332..fb1babc38 100644 --- a/libsrc/pet/crt0.s +++ b/libsrc/pet/crt0.s @@ -9,40 +9,15 @@ .import zerobss, push0 .import _main + .include "zeropage.inc" .include "pet.inc" .include "../cbm/cbm.inc" ; ------------------------------------------------------------------------ -; Define and export the ZP variables for the C64 runtime - - .exportzp sp, sreg, regsave - .exportzp ptr1, ptr2, ptr3, ptr4 - .exportzp tmp1, tmp2, tmp3, tmp4 - .exportzp regbank, zpspace - -.zeropage - -zpstart = * -sp: .res 2 ; Stack pointer -sreg: .res 2 ; Secondary register/high 16 bit for longs -regsave: .res 2 ; slot to save/restore (E)AX into -ptr1: .res 2 -ptr2: .res 2 -ptr3: .res 2 -ptr4: .res 2 -tmp1: .res 1 -tmp2: .res 1 -tmp3: .res 1 -tmp4: .res 1 -regbank: .res 6 ; 6 byte register bank - -zpspace = * - zpstart ; Zero page space allocated +; BASIC header with a SYS call .code -; ------------------------------------------------------------------------ -; BASIC header with a SYS call - .org $3FF .word Head ; Load address Head: .word @Next diff --git a/libsrc/plus4/crt0.s b/libsrc/plus4/crt0.s index 84ffe3aae..701b17258 100644 --- a/libsrc/plus4/crt0.s +++ b/libsrc/plus4/crt0.s @@ -8,40 +8,15 @@ .import initlib, donelib .import push0, _main, zerobss + .include "zeropage.inc" .include "plus4.inc" .include "../cbm/cbm.inc" ; ------------------------------------------------------------------------ -; Define and export the ZP variables for the C64 runtime - - .exportzp sp, sreg, regsave - .exportzp ptr1, ptr2, ptr3, ptr4 - .exportzp tmp1, tmp2, tmp3, tmp4 - .exportzp regbank, zpspace - -.zeropage - -zpstart = * -sp: .res 2 ; Stack pointer -sreg: .res 2 ; Secondary register/high 16 bit for longs -regsave: .res 2 ; slot to save/restore (E)AX into -ptr1: .res 2 -ptr2: .res 2 -ptr3: .res 2 -ptr4: .res 2 -tmp1: .res 1 -tmp2: .res 1 -tmp3: .res 1 -tmp4: .res 1 -regbank: .res 6 ; 6 byte register bank - -zpspace = * - zpstart ; Zero page space allocated +; BASIC header with a SYS call .code -; ------------------------------------------------------------------------ -; BASIC header with a SYS call - .org $0FFF .word Head ; Load address Head: .word @Next -- 2.39.5