* Got dhrystone working - 83/s on a 4MHz Z80!
[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    0x150
25 init:
26         ;; Stack at the top of memory.
27         ld      sp,#0xffff        
28
29         ;; Use _main instead of main to bypass sdcc's intelligence
30         call    __main
31         jp      _exit
32
33         ;; Ordering of segments for the linker.
34         .area   _CODE
35         .area   _DATA
36
37         .area   _CODE
38 _getsp::
39         ld      hl,#0
40         add     hl,sp
41         ret
42         
43 _exit::
44         ;; Exit - special code to the emulator
45         ld      a,#0
46         out     (1),a
47 1$:
48         halt
49         jr      1$