]> git.sur5r.net Git - cc65/blob - libsrc/c1p/crt0.s
Configuration file for assembler-only build.
[cc65] / libsrc / c1p / 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
18 ; ---------------------------------------------------------------------------
19 ; Place the startup code in a special segment
20
21 .segment  "STARTUP"
22
23 ; ---------------------------------------------------------------------------
24 ; A little light 6502 housekeeping
25
26 _init:    ldx     #$FF                 ; Initialize stack pointer to $01FF
27           txs
28           cld                          ; Clear decimal mode
29
30 ; ---------------------------------------------------------------------------
31 ; Initialize screen width
32 ; TODO: Can initialization be done in a more idiomatic way?
33 ; TODO: Create function for changing screen width
34           lda     #$18
35           sta     SCR_LINELEN
36
37 ; ---------------------------------------------------------------------------
38 ; Set cc65 argument stack pointer
39
40           lda     #<(__RAM_START__ + __RAM_SIZE__)
41           sta     sp
42           lda     #>(__RAM_START__ + __RAM_SIZE__)
43           sta     sp+1
44
45 ; ---------------------------------------------------------------------------
46 ; Initialize memory storage
47 ; copydata seems to be only necessary for special systems
48
49           jsr     zerobss              ; Clear BSS segment
50           ; jsr     copydata           ; Initialize DATA segment
51           jsr     initlib              ; Run constructors
52
53 ; ---------------------------------------------------------------------------
54 ; Call main()
55
56           jsr     _main
57
58 ; ---------------------------------------------------------------------------
59 ; Back from main (this is also the _exit entry):  force a software break
60
61 _exit:    jsr     donelib              ; Run destructors
62           brk