2 ; Startup code for cc65 (PET version)
6 .export __STARTUP__ : absolute = 1 ; Mark as startup
7 .import initlib, donelib
13 .include "zeropage.inc"
15 .include "../cbm/cbm.inc"
17 ; ------------------------------------------------------------------------
24 ; Save the zero-page locations that we need.
32 ; Switch to the second charset. The routine that is called by BSOUT to switch the
33 ; character set will use FNLEN as temporary storage -- YUCK! Since the
34 ; initmainargs routine, which parses the command line for arguments, needs that
35 ; information, we need to save and restore it here.
36 ; Thanks to Stefan Haubenthal for this information!
41 ; sta $E84C ; See PET FAQ
44 sta FNLEN ; Restore FNLEN
50 ; Save some system stuff; and, set up the stack.
53 stx spsave ; Save the system stack ptr
58 sta sp+1 ; Set argument stack ptr
60 ; Call the module constructors.
64 ; Push the command-line arguments; and, call main().
68 ; Call the module destructors. This is also the exit() entry.
70 _exit: pha ; Save the return code on stack
73 ; Copy back the zero-page stuff.
81 ; Store the program return code into BASIC's status variable.
86 ; Restore the stack pointer.
89 txs ; Restore stack pointer
95 ; ------------------------------------------------------------------------
101 ; ------------------------------------------------------------------------