Added timing and asm implementations of strcpy, strcmp, memcpy.
[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         jp      __int
23         
24         .org    0x150
25 init:
26         ;; Stack at the top of memory.
27         ld      sp,#0xffff        
28
29         ld      a,#0x01
30         out     (0x09),a
31         ld      a,#0xEF
32         out     (0x07),a
33         
34         ;; Use _main instead of main to bypass sdcc's intelligence
35         ei
36         call    __main
37         jp      _exit
38
39         ;; Ordering of segments for the linker.
40         .area   _CODE
41         .area   _DATA
42
43 __ticks:
44         .ds     2
45         .area   _CODE
46 __int:
47         push    af
48         push    hl
49         ld      hl,#__ticks
50         inc     (hl)
51         jr      nz,1$
52         inc     hl
53         inc     (hl)
54 1$:
55         pop     hl
56         pop     af
57         ei
58         ret
59
60 _clock::
61         ld      hl,#__ticks
62         ld      a,(hl)
63         inc     hl
64         ld      h,(hl)
65         ld      l,a
66         ret
67         
68 _getsp::
69         ld      hl,#0
70         add     hl,sp
71         ret
72         
73 _exit::
74         ;; Exit - special code to the emulator
75         ld      a,#0
76         out     (1),a
77 1$:
78         halt
79         jr      1$