]> git.sur5r.net Git - cc65/blob - libsrc/supervision/crt0.s
Added space after function name.
[cc65] / libsrc / supervision / crt0.s
1 ;
2 ; Startup code for cc65 (supervision version)
3 ;
4
5         .export         _exit
6         .export         __STARTUP__ : absolute = 1      ; Mark as startup
7
8         .import         _main
9         .import         initlib, donelib, copydata
10         .import         zerobss
11         .import         __RAM_START__, __RAM_SIZE__     ; Linker generated
12         .import         __STACKSIZE__                   ; Linker generated
13
14         .include "zeropage.inc"
15         .include "supervision.inc"
16
17         .export _sv_irq_timer_counter, _sv_irq_dma_counter
18         .export _sv_nmi_counter
19
20 .bss
21
22 _sv_irq_dma_counter:    .byte 0
23 _sv_irq_timer_counter:  .byte 0
24 _sv_nmi_counter:        .byte 0
25
26 .code
27
28 reset:
29         jsr     zerobss
30
31         ; Initialize data.
32         jsr     copydata
33
34         lda     #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
35         ldx     #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
36         sta     sp
37         stx     sp+1            ; Set argument stack ptr
38         jsr     initlib
39         jsr     _main
40 _exit:  jsr     donelib
41 exit:   jmp     exit
42
43
44 .proc   irq
45         pha
46         lda     sv_irq_source
47         and     #SV_IRQ_REQUEST_TIMER
48         beq     not_timer
49         lda     sv_timer_quit
50         inc     _sv_irq_timer_counter
51 not_timer:
52         lda     sv_irq_source
53         and     #SV_IRQ_REQUEST_DMA
54         beq     not_dma
55         lda     sv_dma_quit
56         inc     _sv_irq_dma_counter
57 not_dma:
58         pla
59         rti
60 .endproc
61
62 .proc   nmi
63         inc     _sv_nmi_counter
64         rti
65 .endproc
66
67 ; Removing this segment gives only a warning.
68         .segment "FFF0"
69 .proc reset32kcode
70         lda     #(6<<5)
71         sta     sv_bank
72 ; Now, the 32Kbyte image can reside in the top of 64Kbyte and 128Kbyte ROMs.
73         jmp     reset
74 .endproc
75
76         .segment "VECTOR"
77
78 .word   nmi
79 .word   reset32kcode
80 .word   irq
81
82