]> git.sur5r.net Git - cc65/blob - libsrc/osic1p/crt0.s
62342c206e479d619bce354f381e6c1cead7df84
[cc65] / libsrc / osic1p / crt0.s
1 ; ---------------------------------------------------------------------------
2 ; crt0.s
3 ; ---------------------------------------------------------------------------
4 ;
5 ; Startup code for Ohio Scientific Challenger 1P
6
7 .export   _init, _exit
8 .import   _main
9
10 .export   __STARTUP__ : absolute = 1    ; Mark as startup
11 .import   __RAM_START__, __RAM_SIZE__   ; Linker generated
12 .import   __STACKSIZE__
13
14 .import    zerobss, initlib, donelib
15
16 .include  "zeropage.inc"
17 .include  "extzp.inc"
18 .include  "osic1p.inc"
19
20 ; ---------------------------------------------------------------------------
21 ; Place the startup code in a special segment
22
23 .segment  "STARTUP"
24
25 ; ---------------------------------------------------------------------------
26 ; A little light 6502 housekeeping
27
28 _init:    ldx     #$FF          ; Initialize stack pointer to $01FF
29           txs
30           cld                   ; Clear decimal mode
31
32 ; ---------------------------------------------------------------------------
33 ; Set cc65 argument stack pointer
34
35           lda     #<(__RAM_START__ + __RAM_SIZE__  + __STACKSIZE__)
36           sta     sp
37           lda     #>(__RAM_START__ + __RAM_SIZE__  + __STACKSIZE__)
38           sta     sp+1
39
40 ; ---------------------------------------------------------------------------
41 ; Initialize memory storage
42
43           jsr     zerobss       ; Clear BSS segment
44           jsr     initlib       ; Run constructors
45
46 ; ---------------------------------------------------------------------------
47 ; Call main()
48
49           jsr     _main
50
51 ; ---------------------------------------------------------------------------
52 ; Back from main (this is also the _exit entry):
53
54 _exit:    jsr     donelib       ; Run destructors
55           jmp     RESET         ; Display boot menu after program exit