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 __MAIN_START__, __MAIN_SIZE__ ; Linker generated
12 .import __STACKSIZE__ ; Linker generated
15 .include "zeropage.inc"
18 ; ------------------------------------------------------------------------
25 ; Save the zero-page locations that we need.
33 ; Switch to the second charset.
42 ; Save some system stuff; and, set up the stack.
45 stx spsave ; Save the system stack ptr
47 lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
48 ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
50 stx sp+1 ; Set argument stack ptr
52 ; Call the module constructors.
56 ; Push the command-line arguments; and, call main().
60 ; Back from main() [this is also the exit() entry]. Run the 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 BASIC's status variable.
78 ; Restore the stack pointer.
87 ; ------------------------------------------------------------------------
93 ; ------------------------------------------------------------------------