]> git.sur5r.net Git - cc65/blob - libsrc/atari5200/crt0.s
Added SER_ prefix. Whitespace cleanup
[cc65] / libsrc / atari5200 / crt0.s
1 ;
2 ; Startup code for cc65 (Atari5200 version)
3 ;
4 ; Christian Groessler (chris@groessler.org), 2014
5 ;
6
7         .export         _exit, start
8         .export         __STARTUP__ : absolute = 1      ; Mark as startup
9         .import         __RAM_START__, __RAM_SIZE__
10         .import         __RESERVED_MEMORY__
11
12         .import         initlib, donelib, callmain
13         .import         zerobss, copydata
14
15         .include        "zeropage.inc"
16         .include        "atari5200.inc"
17
18 start:
19
20 ; Clear the BSS data.
21
22         jsr     zerobss
23
24 ; Initialize the data.
25         jsr     copydata
26
27 ; Set up the stack.
28
29         lda     #<(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
30         ldx     #>(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
31         sta     sp
32         stx     sp+1            ; Set argument stack ptr
33
34 ; Call the module constructors.
35
36         jsr     initlib
37
38 ; Push the command-line arguments; and, call main().
39
40         jsr     callmain
41
42 ; Call the module destructors. This is also the exit() entry.
43
44 _exit:  jsr     donelib         ; Run module destructors
45
46 ; A 5200 program isn't supposed to exit.
47
48 halt:   jmp halt