* device/lib/gbz80/crt0.s,
[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         ;; Setup global data
34         call    gsinit
35         
36         ;; Use _main instead of main to bypass sdcc's intelligence
37         call    _main
38         jp      _exit
39
40         ;; Ordering of segments for the linker.
41         .area   HOME
42         .area   CODE
43         .area   GSINIT
44         .area   GSFINAL
45         
46         .area   DATA
47         .area   BSS
48         .area   HEAP
49
50         .area   CODE
51 __clock::
52         ld      a,#2
53         rst     0x08
54         ret
55         
56 _exit::
57         ;; Exit - special code to the emulator
58         ld      a,#0
59         rst     0x08
60 1$:
61         halt
62         jr      1$
63
64         .area   GSINIT
65 gsinit::        
66
67         .area   GSFINAL
68         ret