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 ; Place the startup code in a special segment.
22 ; BASIC header with a SYS call
24 .word Head ; Load address
26 .word 1000 ; Line number
27 .byte $9E,"1037" ; SYS 1037
28 .byte $00 ; End of BASIC line
29 @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 ; Push arguments and call main()
72 ; Call module destructors. This is also the _exit entry.
74 _exit: jsr donelib ; Run module destructors
76 ; Restore system stuff
79 txs ; Restore stack pointer
81 ; Copy back the zero page stuff
94 ; ------------------------------------------------------------------------