]> git.sur5r.net Git - cc65/blob - libsrc/geos/devel/crt0.s
Renamed the GEOSZP segment to EXTZP since it is now standard for all
[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, 23.12.2002
7
8         .import         __RAM_START__, __RAM_SIZE__     ; Linker generated
9         .import         initlib, donelib
10         .import         pushax
11         .import         _main
12         .import         _MainLoop, _EnterDeskTop
13         .import         zerobss
14         .importzp       sp
15         .export         _exit
16
17 ; ------------------------------------------------------------------------
18 ; Create an empty LOWCODE segment to avoid linker warnings
19
20 .segment        "LOWCODE"
21
22 ; ------------------------------------------------------------------------
23 ; Place the startup code in a special segment.
24
25 .segment        "STARTUP"
26
27 ; Clear the BSS data
28
29         jsr     zerobss
30
31 ; Setup stack
32
33         lda     #<(__RAM_START__ + __RAM_SIZE__)
34         sta     sp
35         lda     #>(__RAM_START__ + __RAM_SIZE__)
36         sta     sp+1            ; Set argument stack ptr
37
38 ; Call module constructors
39
40         jsr     initlib
41
42 ; Pass an empty command line
43
44         lda     #0
45         tax
46         jsr     pushax          ; argc
47         jsr     pushax          ; argv
48
49         cli
50         ldy     #4              ; Argument size
51         jsr     _main           ; call the users code
52
53 ; Call module destructors. This is also the _exit entry which must be called
54 ; explicitly by the code.
55
56 _exit:  jsr     donelib         ; Run module destructors
57
58         jmp     _EnterDeskTop   ; return control to the system