f4674b6d4f056b327f5da2a7499e531b51912423
[fw/sdcc] / device / lib / gbz80 / crt0.s
1         ;; Generic crt0.s for a GBZ80
2         .globl  _main
3
4         .area _HEADER (ABS)
5         ;; Reset vector
6         .org    0
7         jp      init
8
9         .org    0x08
10         reti
11         .org    0x10
12         reti
13         .org    0x18
14         reti
15         .org    0x20
16         reti
17         .org    0x28
18         reti
19         .org    0x30
20         reti
21         .org    0x38
22         reti
23
24         .org    0x100
25         jp      0x150
26                 
27         .org    0x150
28 init:
29         di
30         ;; Stack at the top of memory.
31         ld      sp,#0xdfff        
32
33         ;; Use _main instead of main to bypass sdcc's intelligence
34         call    _main
35         jp      _exit
36
37         ;; Ordering of segments for the linker.
38         .area   _CODE
39         .area   _GSINIT
40         .area   _GSFINAL
41         
42         .area   _DATA
43         .area   _BSS
44
45         .area   _CODE
46 __clock::
47         ld      a,#2
48         rst     0x08
49         ret
50         
51 _exit::
52         ;; Exit - special code to the emulator
53         ld      a,#0
54         rst     0x08
55 1$:
56         halt
57         jr      1$
58
59         .area   _GSINIT
60 gsinit::        
61
62         .area   _GSFINAL
63         ret