2 ; Startup code for cc65 (Plus/4 version)
4 ; This must be the *first* file on the linker command line
8 .import initlib, donelib
9 .import push0, _main, zerobss
11 .include "zeropage.inc"
13 .include "../cbm/cbm.inc"
15 ; ------------------------------------------------------------------------
16 ; BASIC header with a SYS call
21 .word Head ; Load address
23 .word 1000 ; Line number
24 .byte $9E,"4109" ; SYS 4109
25 .byte $00 ; End of BASIC line
26 @Next: .word 0 ; BASIC end marker
29 ; ------------------------------------------------------------------------
34 sta zpsave,x ; save the zero page locations we need
42 ; Switch to second charset
51 ; Save system stuff and setup the stack
54 stx spsave ; save system stk ptr
57 jsr MEMTOP ; Get top memory
58 cpy #$80 ; We can only use the low 32K :-(
63 sty sp+1 ; set argument stack ptr
65 ; Call module constructors
69 ; Pass an empty command line
74 ldy #4 ; Argument size
75 jsr _main ; call the users code
77 ; Call module destructors. This is also the _exit entry.
79 _exit: jsr donelib ; Run module destructors
81 ; Restore system stuff
86 ; Copy back the zero page stuff
94 ; Reset changed vectors