.SUFFIXES: .o .s .c
%.o: %.c
- @echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
- @echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =
;
.export _exit
- .import __hinit
- .import zerobss, push0, doatexit
+ .import initlib, donelib
+ .import zerobss, push0
.import _main
.include "apple2.inc"
lda #>TOPMEM
sta sp+1 ; Set argument stack ptr
-; Initialize the heap
+; Call module constructors
- jsr __hinit
+ jsr initlib
; Initialize conio stuff
; 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
- sta TEXTTYP
+_exit: jsr donelib
+
+; Restore system stuff
- jsr doatexit ; call exit functions
+ lda #$ff ; Reset text mode
+ sta TEXTTYP
ldx spsave
txs ; Restore stack pointer
.SUFFIXES: .o .s .c
%.o: %.c
- @echo $<
@$(CC) $(CFLAGS) $(ATARIDEFS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
- @echo $<
@$(AS) -g -o $@ $(AFLAGS) $(ATARIDEFS) $<
C_OBJS =
.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
stx old_shflok
sta SHFLOK
-; Initialize the heap
+; Call module constructors
- jsr __hinit
+ jsr initlib
; Initialize conio stuff
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
.SUFFIXES: .o .s .c
%.o: %.c
- @echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
- @echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =
;
.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"
lda #>$C000
sta sp+1
-; Initialize the heap
+; Call module constructors
- jsr __hinit
+ jsr initlib
; Initialize conio stuff
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
.SUFFIXES: .o .s .c
%.o: %.c
- @echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
- @echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =
;
.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"
lda #>$D000
sta sp+1 ; Set argument stack ptr
-; Initialize the heap
+; Call module constructors
- jsr __hinit
+ jsr initlib
; Initialize conio stuff
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
.SUFFIXES: .o .s .c
%.o: %.c
- @echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
- @echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =
.SUFFIXES: .o .s .c
%.o: %.c
- @echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
- @echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =
;
.export _exit
- .import __hinit, push0, doatexit, _main
+ .import initlib, donelib
+ .import push0, _main
.import initconio
.import __BSS_RUN__, __BSS_SIZE__
.import irq, nmi
; 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
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
.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\
;
.export __horg, __hptr, __hend, __hfirst, __hlast
- .export __hinit
+ .constructor initheap, 24
.import __BSS_RUN__, __BSS_SIZE__, __stksize
.importzp sp
.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
sta __hend+1
rts
-
-
-
-
.SUFFIXES: .o .s .c
%.o: %.c
- @echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
- @echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =
.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
#
%.o: %.s
- @echo $<
@$(AS) -o $@ $(AFLAGS) $<
all: $(S_OBJS)
clean:
- @rm -f *.~ $(S_OBJS) core
\ No newline at end of file
+ @rm -f *.~ $(S_OBJS) core
; 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
lda #>$7900
sta sp+1 ; Set argument stack ptr
-; Initialize the heap
+; Call module constructors
-;;! jsr __hinit
+ jsr initlib
; Pass an empty command line
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
+
#
# Makefile for GEOS lib
# for cc65
-#
+#
%.o: %.s
- @echo $<
@$(AS) -o $@ $(AFLAGS) $<
all: $(S_OBJS)
clean:
- @rm -f *.~ $(S_OBJS) core
\ No newline at end of file
+ @rm -f *.~ $(S_OBJS) core
#
%.o: %.s
- @echo $<
@$(AS) -o $@ $(AFLAGS) $<
all: $(S_OBJS)
clean:
- @rm -f *.~ $(S_OBJS) core
\ No newline at end of file
+ @rm -f *.~ $(S_OBJS) core
#
# Makefile for GEOS lib
# for cc65
-#
+#
%.o: %.s
- @echo $<
@$(AS) -o $@ $(AFLAGS) $<
all: $(S_OBJS)
clean:
- @rm -f *.~ $(S_OBJS) core
\ No newline at end of file
+ @rm -f *.~ $(S_OBJS) core
#
%.o: %.s
- @echo $<
@$(AS) -o $@ $(AFLAGS) $<
all: $(S_OBJS)
clean:
- @rm -f *.~ $(S_OBJS) core
\ No newline at end of file
+ @rm -f *.~ $(S_OBJS) core
#
%.o: %.s
- @echo $<
@$(AS) -o $@ $(AFLAGS) $<
all: $(S_OBJS)
clean:
- @rm -f *.~ $(S_OBJS) core
\ No newline at end of file
+ @rm -f *.~ $(S_OBJS) core
#
%.o: %.s
- @echo $<
@$(AS) -o $@ $(AFLAGS) $<
all: $(S_OBJS)
clean:
- @rm -f *.~ $(S_OBJS) core
\ No newline at end of file
+ @rm -f *.~ $(S_OBJS) core
#
%.o: %.s
- @echo $<
@$(AS) -o $@ $(AFLAGS) $<
all: $(S_OBJS)
clean:
- @rm -f *.~ $(S_OBJS) core
\ No newline at end of file
+ @rm -f *.~ $(S_OBJS) core
#
%.o: %.s
- @echo $<
@$(AS) -o $@ $(AFLAGS) $<
all: $(S_OBJS)
clean:
- @rm -f *.~ $(S_OBJS) core
\ No newline at end of file
+ @rm -f *.~ $(S_OBJS) core
#
%.o: %.s
- @echo $<
@$(AS) -o $@ $(AFLAGS) $<
all: $(S_OBJS)
clean:
- @rm -f *.~ $(S_OBJS) core
\ No newline at end of file
+ @rm -f *.~ $(S_OBJS) core
.SUFFIXES: .o .s .c
%.o: %.c
- @echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
- @echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =
; 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"
lda MEMSIZE+1
sta sp+1 ; Set argument stack ptr
-; Initialize the heap
+; Call module constructors
- jsr __hinit
+ jsr initlib
; Initialize conio stuff
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
.SUFFIXES: .o .s .c
%.o: %.c
- @echo $<
@$(CC) $(CFLAGS) $<
@$(AS) -o $@ $(AFLAGS) $(*).s
%.o: %.s
- @echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
C_OBJS =
; 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"
MemOk: stx sp
sty sp+1 ; set argument stack ptr
-; Initialize the heap
+; Call module constructors
- jsr __hinit
+ jsr initlib
; Initialize conio stuff
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
.SUFFIXES: .o .s .c
.c.s:
- @echo $<
@$(CC) $(CFLAGS) $<
.s.o:
- @echo $<
@$(AS) -g -o $@ $(AFLAGS) $<
OBJS = add.o \
; 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__
; --------------------------------------------------------------------------
; Initialize library modules
-.proc libinit
+.proc initlib
lda #<__CONSTRUCTOR_TABLE__
ldx #>__CONSTRUCTOR_TABLE__
; --------------------------------------------------------------------------
; 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