]> git.sur5r.net Git - cc65/blob - libsrc/geos/devel/crt0.s
Return 0 if color not found
[cc65] / libsrc / geos / devel / crt0.s
1 ;
2 ; This must be the *second* file on the linker command line
3 ; (.cvt header must be the *first* one)
4
5 ; Maciej 'YTM/Elysium' Witkowiak
6 ; 26.10.99, 10.3.2000, 15.8.2001
7
8 ; no __hinit
9
10         .export         _exit
11         .import         initlib, donelib
12         .import         pushax
13         .import         _main
14         .import         zerobss
15
16 ; ------------------------------------------------------------------------
17 ; Define and export the ZP variables for the C64 runtime
18
19         .exportzp       sp, sreg, regsave, regbank
20         .exportzp       ptr1, ptr2, ptr3, ptr4
21         .exportzp       tmp1, tmp2, tmp3, tmp4
22
23 sp      =       $72             ; stack pointer
24 sreg    =       $74             ; secondary register/high 16 bit for longs
25 regsave =       $76             ; slot to save/restore (E)AX into
26 ptr1    =       $7A             ;
27 ptr2    =       $7C
28 ptr3    =       $7E
29 ptr4    =       $70
30 tmp1    =       $fb
31 tmp2    =       $fc
32 tmp3    =       $fd
33 tmp4    =       $fe
34
35 regbank =       $a3             ; 6 bytes hopefully not used by Kernal
36
37 ; ------------------------------------------------------------------------
38
39 ;       .org $0400-508          ; $0400 - length of .cvt header
40 ;       .include "cvthead.s"
41
42         .reloc
43
44 ; ------------------------------------------------------------------------
45 ; Create an empty LOWCODE segment to avoid linker warnings
46
47 .segment        "LOWCODE"
48
49 ; ------------------------------------------------------------------------
50 ; Place the startup code in a special segment.
51
52 .segment        "STARTUP"
53
54 ; Clear the BSS data
55
56         jsr     zerobss
57
58 ; Setup stack
59
60         lda     #<$6000
61         sta     sp
62         lda     #>$6000
63         sta     sp+1            ; Set argument stack ptr
64
65 ; Call module constructors
66
67         jsr     initlib
68
69 ; Pass an empty command line
70
71         lda     #0
72         tax
73         jsr     pushax          ; argc
74         jsr     pushax          ; argv
75
76         cli
77         ldy     #4              ; Argument size
78         jsr     _main           ; call the users code
79         jmp     $c1c3           ; jump to GEOS MainLoop
80
81 ; Call module destructors. This is also the _exit entry which must be called
82 ; explicitly by the code.
83
84 _exit:  jsr     donelib         ; Run module destructors
85
86         jmp     $c22c           ; EnterDeskTop
87