2 ; Startup code for cc65 (Plus/4 version)
4 ; This must be the *first* file on the linker command line
8 .import __hinit, push0, doatexit, _main
9 .import initconio, doneconio, zerobss
12 .include "../cbm/cbm.inc"
14 ; ------------------------------------------------------------------------
15 ; Define and export the ZP variables for the C64 runtime
17 .exportzp sp, sreg, regsave
18 .exportzp ptr1, ptr2, ptr3, ptr4
19 .exportzp tmp1, tmp2, tmp3, tmp4
20 .exportzp regbank, zpspace
22 sp = $02 ; stack pointer
23 sreg = $04 ; secondary register/high 16 bit for longs
24 regsave = $06 ; slot to save/restore (E)AX into
33 regbank = $16 ; 6 byte register bank
34 zpspace = $1A ; Zero page space allocated
36 ; ------------------------------------------------------------------------
37 ; BASIC header with a SYS call
40 .word Head ; Load address
42 .word 1000 ; Line number
43 .byte $9E,"4109" ; SYS 4109
44 .byte $00 ; End of BASIC line
45 @Next: .word 0 ; BASIC end marker
48 ; ------------------------------------------------------------------------
53 sta zpsave,y ; save the zero page locations we need
61 ; Switch to second charset
70 ; Save system stuff and setup the stack
73 stx spsave ; save system stk ptr
76 jsr MEMTOP ; Get top memory
77 cpy #$80 ; We can only use the low 32K :-(
82 sty sp+1 ; set argument stack ptr
88 ; Initialize conio stuff
92 ; Pass an empty command line
97 ldy #4 ; Argument size
98 jsr _main ; call the users code
100 ; fall thru to exit...
102 _exit: jsr doatexit ; call exit functions
106 ; Reset the conio stuff
110 ; Copy back the zero page stuff
118 ; Reset changed vectors