]> git.sur5r.net Git - cc65/blob - libsrc/geos/devel/crt0.s
GEOS no longer requires explicit exit() call, now explicit MainLoop() is required
[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 GEOSZP segment to avoid linker warnings
19
20 .segment        "GEOSZP", zeropage
21
22 ; ------------------------------------------------------------------------
23 ; Create an empty LOWCODE segment to avoid linker warnings
24
25 .segment        "LOWCODE"
26
27 ; ------------------------------------------------------------------------
28 ; Place the startup code in a special segment.
29
30 .segment        "STARTUP"
31
32 ; Clear the BSS data
33
34         jsr     zerobss
35
36 ; Setup stack
37
38         lda     #<(__RAM_START__ + __RAM_SIZE__)
39         sta     sp
40         lda     #>(__RAM_START__ + __RAM_SIZE__)
41         sta     sp+1            ; Set argument stack ptr
42
43 ; Call module constructors
44
45         jsr     initlib
46
47 ; Pass an empty command line
48
49         lda     #0
50         tax
51         jsr     pushax          ; argc
52         jsr     pushax          ; argv
53
54         cli
55         ldy     #4              ; Argument size
56         jsr     _main           ; call the users code
57
58 ; Call module destructors. This is also the _exit entry which must be called
59 ; explicitly by the code.
60
61 _exit:  jsr     donelib         ; Run module destructors
62
63         jmp     _EnterDeskTop   ; return control to the system