2 ; Startup code for cc65 (PET version)
4 ; This must be the *first* file on the linker command line
8 .import initlib, donelib
12 .include "zeropage.inc"
14 .include "../cbm/cbm.inc"
16 ; ------------------------------------------------------------------------
17 ; BASIC header with a SYS call
22 .word Head ; Load address
24 .word 1000 ; Line number
25 .byte $9E,"1037" ; SYS 1037
26 .byte $00 ; End of BASIC line
27 @Next: .word 0 ; BASIC end marker
30 ; ------------------------------------------------------------------------
35 sta zpsave,x ; Save the zero page locations we need
43 ; Switch to second charset
46 ; sta $E84C ; See PET FAQ
53 ; Save system stuff and setup the stack
56 stx spsave ; Save the system stack ptr
61 sta sp+1 ; Set argument stack ptr
63 ; Call module constructors
67 ; Pass an empty command line
72 ldy #4 ; Argument size
73 jsr _main ; call the users code
75 ; Call module destructors. This is also the _exit entry.
77 _exit: jsr donelib ; Run module destructors
79 ; Restore system stuff
82 txs ; Restore stack pointer
84 ; Copy back the zero page stuff