ce0176f9c89b871c4c69471d867b2d03a8285f2e
[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         ei
31         call    __main
32         jp      _exit
33
34         ;; Ordering of segments for the linker.
35         .area   _CODE
36         .area   _DATA
37
38 __clock::
39         ld      a,#2
40         out     (0xff),a
41         ret
42         
43 _getsp::
44         ld      hl,#0
45         add     hl,sp
46         ret
47
48 __printTStates::        
49         ld      a,#3
50         out     (0xff),a
51         ret
52                 
53 _exit::
54         ;; Exit - special code to the emulator
55         ld      a,#1
56         out     (0xff),a
57 1$:
58         halt
59         jr      1$