2 ; Startup code for cc65 (PET version)
4 ; This must be the *first* file on the linker command line
8 .import initlib, donelib
13 .include "zeropage.inc"
15 .include "../cbm/cbm.inc"
17 ; ------------------------------------------------------------------------
18 ; BASIC header with a SYS call
23 .word Head ; Load address
25 .word 1000 ; Line number
26 .byte $9E,"1037" ; SYS 1037
27 .byte $00 ; End of BASIC line
28 @Next: .word 0 ; BASIC end marker
31 ; ------------------------------------------------------------------------
36 sta zpsave,x ; Save the zero page locations we need
44 ; Switch to second charset
47 ; sta $E84C ; See PET FAQ
54 ; Save system stuff and setup the stack
57 stx spsave ; Save the system stack ptr
62 sta sp+1 ; Set argument stack ptr
64 ; Call module constructors
68 ; Pass an empty command line
73 ldy #4 ; Argument size
74 jsr _main ; call the users code
76 ; Call module destructors. This is also the _exit entry.
78 _exit: jsr donelib ; Run module destructors
80 ; Restore system stuff
83 txs ; Restore stack pointer
85 ; Copy back the zero page stuff