eb015280ea44f56e557bfb86031dcc953691831e
[fw/sdcc] / device / lib / gbz80 / 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         jp      0x150
26                 
27         .org    0x150
28 init:
29         di
30         ;; Stack at the top of memory.
31         ld      sp,#0xdfff        
32
33         ;; Use _main instead of main to bypass sdcc's intelligence
34         call    __main
35         jp      _exit
36
37         ;; Ordering of segments for the linker.
38         .area   _CODE
39         .area   _DATA
40
41 __clock::
42         ld      a,#2
43         rst     0x00
44         ret
45         
46 _getsp::
47         ld      hl,#0
48         add     hl,sp
49         ret
50
51 __printTStates::        
52         ld      a,#3
53         rst     0x00
54         ret
55                 
56 _exit::
57         ;; Exit - special code to the emulator
58         ld      a,#1
59         rst     0x00
60 1$:
61         halt
62         jr      1$