]> git.sur5r.net Git - cc65/blob - libsrc/gamate/crt0.s
moved cart header into seperate file, moved nmi stub into several file, tweaked linke...
[cc65] / libsrc / gamate / crt0.s
1
2         .export         Start, _exit
3
4         .import         initlib, donelib, callmain
5         .import         push0, _main, zerobss, copydata
6
7         ; Linker generated symbols
8         .import         __RAM_START__, __RAM_SIZE__
9
10         .include        "zeropage.inc"
11         .include        "gamate.inc"
12
13 Start:
14         ; setup the CPU and System-IRQ
15
16         ; Initialize CPU
17         sei
18         cld
19
20         ; Setup stack and memory mapping
21         ldx     #$FF            ; Stack top ($01FF)
22         txs
23
24         ; Clear the BSS data
25         jsr     zerobss
26
27         ; Copy the .data segment to RAM
28         jsr     copydata
29
30         ; setup the stack
31         lda     #<(__RAM_START__+__RAM_SIZE__)
32         sta     sp
33         lda     #>(__RAM_START__+__RAM_SIZE__)
34         sta     sp + 1
35
36         ; Call module constructors
37         jsr     initlib
38
39         cli     ; allow IRQ only after constructors have run
40
41         ; Pass an empty command line
42         jsr     push0           ; argc
43         jsr     push0           ; argv
44
45         ldy     #4              ; Argument size
46         jsr     _main           ; call the users code
47
48         ; Call module destructors. This is also the _exit entry.
49 _exit:
50         jsr     donelib         ; Run module destructors
51
52         ; reset (start over)
53         jmp     Start
54
55         .export initmainargs
56 initmainargs:
57         rts