2 ; Startup code for cc65 (Vic20 version)
6 .export __STARTUP__ : absolute = 1 ; Mark as startup
7 .import initlib, donelib
10 .import RESTOR, BSOUT, CLRCH
11 .import __RAM_START__, __RAM_SIZE__ ; Linker generated
12 .import __STACKSIZE__ ; Linker generated
15 .include "zeropage.inc"
18 ; ------------------------------------------------------------------------
25 ; Save the zero page locations we need
33 ; Switch to second charset
42 ; Save system stuff and setup the stack
45 stx spsave ; Save the system stack ptr
47 lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
49 lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
50 sta sp+1 ; Set argument stack ptr
52 ; Call module constructors
56 ; Push arguments and call main()
60 ; Back from main (This is also the _exit entry). Run module destructors
62 _exit: pha ; Save the return code on stack
65 ; Copy back the zero page stuff
73 ; Place the program return code into ST
78 ; Restore the stack pointer
87 ; ------------------------------------------------------------------------
93 ; ------------------------------------------------------------------------