]> git.sur5r.net Git - cc65/blob - libsrc/osic1p/crt0.s
0db447bb0312d72a3f3db4f74f4d3a24c36ddfbe
[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
13 .import    zerobss, initlib, donelib
14
15 .include  "zeropage.inc"
16 .include  "extzp.inc"
17 .include  "osic1p.inc"
18
19 ; ---------------------------------------------------------------------------
20 ; Place the startup code in a special segment
21
22 .segment  "STARTUP"
23
24 ; ---------------------------------------------------------------------------
25 ; A little light 6502 housekeeping
26
27 _init:    ldx     #$FF                 ; Initialize stack pointer to $01FF
28           txs
29           cld                          ; Clear decimal mode
30
31 ; ---------------------------------------------------------------------------
32 ; Set cc65 argument stack pointer
33
34           lda     #<(__RAM_START__ + __RAM_SIZE__)
35           sta     sp
36           lda     #>(__RAM_START__ + __RAM_SIZE__)
37           sta     sp+1
38
39 ; ---------------------------------------------------------------------------
40 ; Initialize memory storage
41 ; copydata seems to be only necessary for special systems
42
43           jsr     zerobss              ; Clear BSS segment
44           ; jsr     copydata           ; Initialize DATA segment
45           jsr     initlib              ; Run constructors
46
47 ; ---------------------------------------------------------------------------
48 ; Call main()
49
50           jsr     _main
51
52 ; ---------------------------------------------------------------------------
53 ; Back from main (this is also the _exit entry):  force a software break
54
55 _exit:    jsr     donelib              ; Run destructors
56           jmp     RESET                ; Display boot menu after program exit