]> git.sur5r.net Git - cc65/blob - libsrc/geos/devel/crt0.s
Use the condes feature
[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/Alliance' Witkowiak
6 ; 26.10.99, 10.3.2000
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 ; Actual code
46
47 ; Clear the BSS data
48
49         jsr     zerobss
50
51 ; Setup stack
52
53         lda     #<$7900
54         sta     sp
55         lda     #>$7900
56         sta     sp+1            ; Set argument stack ptr
57
58 ; Call module constructors
59
60         jsr     initlib
61
62 ; Pass an empty command line
63
64         lda     #0
65         tax
66         jsr     pushax          ; argc
67         jsr     pushax          ; argv
68
69         ldy     #4              ; Argument size
70         jsr     _main           ; call the users code
71         jmp     $c1c3           ; jump to GEOS MainLoop
72
73 ; Call module destructors. This is also the _exit entry which must be called
74 ; explicitly by the code.
75
76 _exit:  jsr     donelib         ; Run module destructors
77
78         jmp     $c22c           ; EnterDeskTop
79