Use the condes feature

git-svn-id: svn://svn.cc65.org/cc65/trunk@470 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2000-11-22 22:19:09 +00:00
parent cefb4c067d
commit f3b93741ab
32 changed files with 104 additions and 129 deletions

View File

@ -5,12 +5,10 @@
.SUFFIXES: .o .s .c
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
@echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =

View File

@ -5,8 +5,8 @@
;
.export _exit
.import __hinit
.import zerobss, push0, doatexit
.import initlib, donelib
.import zerobss, push0
.import _main
.include "apple2.inc"
@ -66,9 +66,9 @@ L1: lda sp,x
lda #>TOPMEM
sta sp+1 ; Set argument stack ptr
; Initialize the heap
; Call module constructors
jsr __hinit
jsr initlib
; Initialize conio stuff
@ -77,23 +77,25 @@ L1: lda sp,x
; Set up to use Apple ROM $C000-$CFFF
;; sta USEROM
;; sta USEROM
; Pass an empty command line
jsr push0 ; argc
jsr push0 ; argv
jsr push0 ; argc
jsr push0 ; argv
ldy #4 ; Argument size
jsr _main ; call the users code
ldy #4 ; Argument size
jsr _main ; call the users code
; fall thru to exit...
; Call module destructors. This is also the _exit entry.
_exit: lda #$ff
_exit: jsr donelib
; Restore system stuff
lda #$ff ; Reset text mode
sta TEXTTYP
jsr doatexit ; call exit functions
ldx spsave
txs ; Restore stack pointer

View File

@ -8,12 +8,10 @@ ATARIDEFS = -DNUMDRVS=4
.SUFFIXES: .o .s .c
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $(ATARIDEFS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
@echo $<
@$(AS) -g -o $@ $(AFLAGS) $(ATARIDEFS) $<
C_OBJS =

View File

@ -15,8 +15,9 @@ RESERVE_MOUSE_MEMORY = 1 ; for P/M
.export mouse_pm0
.endif
.export _exit
.import getargs, argc, argv
.import __hinit, initconio, zerobss, pushax, doatexit
.import getargs, argc, argv
.import initlib, donelib
.import initconio, zerobss, pushax
.import _main,__filetab,getfd
.import __CODE_LOAD__, __BSS_LOAD__
.import __graphmode_used
@ -117,9 +118,9 @@ L1: lda sp,x
stx old_shflok
sta SHFLOK
; Initialize the heap
; Call module constructors
jsr __hinit
jsr initlib
; Initialize conio stuff
@ -146,20 +147,22 @@ L1: lda sp,x
lda argc
ldx argc+1
jsr pushax ; argc
jsr pushax ; argc
lda #<argv
ldx #>argv
jsr pushax ; argv
jsr pushax ; argv
ldy #4 ; Argument size
jsr _main ; call the users code
ldy #4 ; Argument size
jsr _main ; call the users code
; fall thru to exit...
; Call module destructors. This is also the _exit entry.
_exit: jsr doatexit ; call exit functions
_exit: jsr donelib ; Run module destructors
; Restore system stuff
ldx spsave
txs ; Restore stack pointer
txs ; Restore stack pointer
; restore left margin

View File

@ -5,12 +5,10 @@
.SUFFIXES: .o .s .c
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
@echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =

View File

@ -5,8 +5,9 @@
;
.export _exit
.import __hinit, initconio, doneconio, zerobss
.import push0, doatexit, _main
.import initlib, donelib
.import initconio, doneconio, zerobss
.import push0, _main
.include "c128.inc"
.include "../cbm/cbm.inc"
@ -93,9 +94,9 @@ L1: lda sp,x
lda #>$C000
sta sp+1
; Initialize the heap
; Call module constructors
jsr __hinit
jsr initlib
; Initialize conio stuff
@ -109,9 +110,9 @@ L1: lda sp,x
ldy #4 ; Argument size
jsr _main ; call the users code
; fall thru to exit...
; Call module destructors. This is also the _exit entry.
_exit: jsr doatexit ; call exit functions
_exit: jsr donelib ; Run module destructors
; Reset the conio stuff

View File

@ -5,12 +5,10 @@
.SUFFIXES: .o .s .c
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
@echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =

View File

@ -5,12 +5,10 @@
;
.export _exit
.import __hinit, initconio, zerobss, push0, condes
.import initlib, donelib
.import initconio, zerobss, push0
.import _main
.import __CONSTRUCTOR_TABLE__, __CONSTRUCTOR_COUNT__
.import __DESTRUCTOR_TABLE__, __DESTRUCTOR_COUNT__
.include "c64.inc"
.include "../cbm/cbm.inc"
@ -92,9 +90,9 @@ L1: lda sp,x
lda #>$D000
sta sp+1 ; Set argument stack ptr
; Initialize the heap
; Call module constructors
jsr __hinit
jsr initlib
; Initialize conio stuff
@ -108,12 +106,9 @@ L1: lda sp,x
ldy #4 ; Argument size
jsr _main ; call the users code
; Call module destructors
; Call module destructors. This is also the _exit entry.
_exit: lda #<__DESTRUCTOR_TABLE__
ldx #>__DESTRUCTOR_TABLE__
ldy #<(__DESTRUCTOR_COUNT__*2)
jsr condes
_exit: jsr donelib ; Run module destructors
; Restore system stuff

View File

@ -5,12 +5,10 @@
.SUFFIXES: .o .s .c
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
@echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =

View File

@ -5,12 +5,10 @@
.SUFFIXES: .o .s .c
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
@echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =

View File

@ -5,7 +5,8 @@
;
.export _exit
.import __hinit, push0, doatexit, _main
.import initlib, donelib
.import push0, _main
.import initconio
.import __BSS_RUN__, __BSS_SIZE__
.import irq, nmi
@ -235,9 +236,13 @@ Z4:
; This code is in page 2, so we may now start calling subroutines safely,
; since the code we execute is no longer in the stack page.
; Call module constructors
jsr __hinit ; Initialize the heap
jsr initconio ; Initialize conio stuff
jsr initlib
; Initialize conio stuff
jsr initconio
; Create the (empty) command line for the program
@ -323,9 +328,9 @@ Start:
ldy #4 ; Argument size
jsr _main ; call the users code
; Fall thru to exit.
; Call module destructors. This is also the _exit entry.
_exit: jsr doatexit ; call exit functions
_exit: jsr donelib ; Run module destructors
; Clear the start of the zero page, since it will be interpreted as a
; (garbage) BASIC program otherwise. This is also the default entry for

View File

@ -5,12 +5,10 @@
.SUFFIXES: .o .s .c
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -g -o $@ $(AFLAGS) $(*).s
%.o: %.s
@echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS = fclose.o fgets.o fprintf.o calloc.o _fopen.o\

View File

@ -5,7 +5,7 @@
;
.export __horg, __hptr, __hend, __hfirst, __hlast
.export __hinit
.constructor initheap, 24
.import __BSS_RUN__, __BSS_SIZE__, __stksize
.importzp sp
@ -17,19 +17,17 @@ __hptr:
.word __BSS_RUN__+__BSS_SIZE__ ; Dito
__hend:
.word __BSS_RUN__+__BSS_SIZE__
__hfirst:
__hfirst:
.word 0
__hlast:
.word 0
;
; Initialization. Must be called from startup!
;
; Initialization. Will be called from startup!
.code
__hinit:
initheap:
sec
lda sp
sbc __stksize
@ -39,7 +37,3 @@ __hinit:
sta __hend+1
rts

View File

@ -5,12 +5,10 @@
.SUFFIXES: .o .s .c
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
@echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =

View File

@ -5,12 +5,10 @@
.SUFFIXES: .o .s .c
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -g -o $@ $(AFLAGS) $(*).s
%.o: %.s
@echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS = dbg.o

View File

@ -5,7 +5,6 @@
#
%.o: %.s
@echo $<
@$(AS) -o $@ $(AFLAGS) $<
@ -14,4 +13,4 @@ S_OBJS = crt0.o
all: $(S_OBJS)
clean:
@rm -f *.~ $(S_OBJS) core
@rm -f *.~ $(S_OBJS) core

View File

@ -7,10 +7,11 @@
; no __hinit
.export _exit
.export _exit
.import initlib, donelib
.import pushax
.import _main
.import zerobss, doatexit
.import zerobss
; ------------------------------------------------------------------------
; Define and export the ZP variables for the C64 runtime
@ -54,9 +55,9 @@ regbank = $a3 ; 6 bytes hopefully not used by Kernal
lda #>$7900
sta sp+1 ; Set argument stack ptr
; Initialize the heap
; Call module constructors
;;! jsr __hinit
jsr initlib
; Pass an empty command line
@ -69,9 +70,10 @@ regbank = $a3 ; 6 bytes hopefully not used by Kernal
jsr _main ; call the users code
jmp $c1c3 ; jump to GEOS MainLoop
; exit must be called from the code!
; Call module destructors. This is also the _exit entry which must be called
; explicitly by the code.
_exit:
jsr doatexit ; call exit functions
_exit: jsr donelib ; Run module destructors
jmp $c22c ; EnterDeskTop
jmp $c22c ; EnterDeskTop

View File

@ -1,10 +1,9 @@
#
# Makefile for GEOS lib
# for cc65
#
#
%.o: %.s
@echo $<
@$(AS) -o $@ $(AFLAGS) $<
@ -17,4 +16,4 @@ S_OBJS = blkalloc.o calcblksfree.o changediskdevice.o chkdkgeos.o enterturbo.o e
all: $(S_OBJS)
clean:
@rm -f *.~ $(S_OBJS) core
@rm -f *.~ $(S_OBJS) core

View File

@ -5,7 +5,6 @@
#
%.o: %.s
@echo $<
@$(AS) -o $@ $(AFLAGS) $<
@ -16,4 +15,4 @@ S_OBJS = dodlgbox.o rstrfrmdialogue.o\
all: $(S_OBJS)
clean:
@rm -f *.~ $(S_OBJS) core
@rm -f *.~ $(S_OBJS) core

View File

@ -1,10 +1,9 @@
#
# Makefile for GEOS lib
# for cc65
#
#
%.o: %.s
@echo $<
@$(AS) -o $@ $(AFLAGS) $<
@ -18,4 +17,4 @@ S_OBJS = get1stdirentry.o getnxtdirentry.o\
all: $(S_OBJS)
clean:
@rm -f *.~ $(S_OBJS) core
@rm -f *.~ $(S_OBJS) core

View File

@ -5,7 +5,6 @@
#
%.o: %.s
@echo $<
@$(AS) -o $@ $(AFLAGS) $<
@ -19,4 +18,4 @@ S_OBJS = drawline.o drawpoint.o framerectangle.o hlineregs.o horizontalline.o\
all: $(S_OBJS)
clean:
@rm -f *.~ $(S_OBJS) core
@rm -f *.~ $(S_OBJS) core

View File

@ -5,7 +5,6 @@
#
%.o: %.s
@echo $<
@$(AS) -o $@ $(AFLAGS) $<
@ -16,4 +15,4 @@ S_OBJS = crc.o doublepop.o reuregs.o clearram.o fillram.o initram.o movedata.o\
all: $(S_OBJS)
clean:
@rm -f *.~ $(S_OBJS) core
@rm -f *.~ $(S_OBJS) core

View File

@ -5,7 +5,6 @@
#
%.o: %.s
@echo $<
@$(AS) -o $@ $(AFLAGS) $<
@ -15,4 +14,4 @@ S_OBJS = domenu.o dopreviousmenu.o redomenu.o recovermenu.o recoverallmenus.o\
all: $(S_OBJS)
clean:
@rm -f *.~ $(S_OBJS) core
@rm -f *.~ $(S_OBJS) core

View File

@ -5,7 +5,6 @@
#
%.o: %.s
@echo $<
@$(AS) -o $@ $(AFLAGS) $<
@ -17,4 +16,4 @@ S_OBJS = startmousemode.o clearmousemode.o mouseup.o mouseoff.o\
all: $(S_OBJS)
clean:
@rm -f *.~ $(S_OBJS) core
@rm -f *.~ $(S_OBJS) core

View File

@ -5,7 +5,6 @@
#
%.o: %.s
@echo $<
@$(AS) -o $@ $(AFLAGS) $<
@ -14,4 +13,4 @@ S_OBJS = processinitrestartenable.o processblock.o processfreeze.o sleep.o
all: $(S_OBJS)
clean:
@rm -f *.~ $(S_OBJS) core
@rm -f *.~ $(S_OBJS) core

View File

@ -5,7 +5,6 @@
#
%.o: %.s
@echo $<
@$(AS) -o $@ $(AFLAGS) $<
@ -15,4 +14,4 @@ S_OBJS = callroutine.o enterdesktop.o firstinit.o getrandom.o getserialnumber.o\
all: $(S_OBJS)
clean:
@rm -f *.~ $(S_OBJS) core
@rm -f *.~ $(S_OBJS) core

View File

@ -5,12 +5,10 @@
.SUFFIXES: .o .s .c
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
@echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =

View File

@ -4,8 +4,9 @@
; This must be the *first* file on the linker command line
;
.export _exit
.import __hinit, initconio, zerobss, push0, doatexit
.export _exit
.import initlib, donelib
.import initconio, zerobss, push0
.import _main
.include "pet.inc"
@ -84,9 +85,9 @@ L1: lda sp,x
lda MEMSIZE+1
sta sp+1 ; Set argument stack ptr
; Initialize the heap
; Call module constructors
jsr __hinit
jsr initlib
; Initialize conio stuff
@ -100,9 +101,11 @@ L1: lda sp,x
ldy #4 ; Argument size
jsr _main ; call the users code
; fall thru to exit...
; Call module destructors. This is also the _exit entry.
_exit: jsr doatexit ; call exit functions
_exit: jsr donelib ; Run module destructors
; Restore system stuff
ldx spsave
txs ; Restore stack pointer

View File

@ -5,12 +5,10 @@
.SUFFIXES: .o .s .c
%.o: %.c
@echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
@echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =

View File

@ -4,8 +4,9 @@
; This must be the *first* file on the linker command line
;
.export _exit
.import __hinit, push0, doatexit, _main
.export _exit
.import initlib, donelib
.import push0, _main
.import initconio, doneconio, zerobss
.include "plus4.inc"
@ -87,9 +88,9 @@ L1: lda sp,x
MemOk: stx sp
sty sp+1 ; set argument stack ptr
; Initialize the heap
; Call module constructors
jsr __hinit
jsr initlib
; Initialize conio stuff
@ -103,9 +104,12 @@ MemOk: stx sp
ldy #4 ; Argument size
jsr _main ; call the users code
; fall thru to exit...
; Call module destructors. This is also the _exit entry.
_exit: jsr donelib ; Run module destructors
; Restore system stuff
_exit: jsr doatexit ; call exit functions
ldx spsave
txs

View File

@ -5,11 +5,9 @@
.SUFFIXES: .o .s .c
.c.s:
@echo $<
@$(CC) $(CFLAGS) $<
.s.o:
@echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
OBJS = add.o \

View File

@ -16,7 +16,7 @@
; lies in the data segment so it's address may be patched at runtime.
;
.export libinit, libdone, condes
.export initlib, donelib, condes
.export jmpvec
.import __CONSTRUCTOR_TABLE__, __CONSTRUCTOR_COUNT__
@ -29,7 +29,7 @@
; --------------------------------------------------------------------------
; Initialize library modules
.proc libinit
.proc initlib
lda #<__CONSTRUCTOR_TABLE__
ldx #>__CONSTRUCTOR_TABLE__
@ -43,12 +43,12 @@
; --------------------------------------------------------------------------
; Cleanup library modules
.proc libdone
.proc donelib
lda #<__DESTRUCTOR_TABLE__
ldx #>__DESTRUCTOR_TABLE__
ldy #<(__DESTRUCTOR_COUNT__*2)
bne condes
lda #<__DESTRUCTOR_TABLE__
ldx #>__DESTRUCTOR_TABLE__
ldy #<(__DESTRUCTOR_COUNT__*2)
bne condes
rts
.endproc