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