dee9a4bfbb18194e55e9c406b9036659239f0ed1
[fw/sdcc] / device / lib / z80 / crt0.s
1         ;; Generic crt0.s for a Z80
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 init:
26         ;; Stack at the top of memory.
27         ld      sp,#0xffff        
28
29         ;; Initialise global variables
30         call    gsinit
31         call    _main
32         jp      _exit
33
34         ;; Ordering of segments for the linker.
35         .area   _CODE
36         .area   _GSINIT
37         .area   _GSFINAL
38         
39         .area   _DATA
40         .area   _BSS
41
42         .area   _CODE
43 __clock::
44         ld      a,#2
45         out     (0xff),a
46         ret
47         
48 _getsp::
49         ld      hl,#0
50         add     hl,sp
51         ret
52
53 __printTStates::        
54         ld      a,#3
55         out     (0xff),a
56         ret
57
58 _exit::
59         ;; Exit - special code to the emulator
60         ld      a,#0
61         rst     0x08
62 1$:
63         halt
64         jr      1$
65
66         .area   _GSINIT
67 gsinit::        
68
69         .area   _GSFINAL
70         ret