Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc-extra / historygraphs / whetstone-z80 / crt0.s
blobf566b5ea83d27680bc50960fff5e5a1b7d644b61
1 ;--------------------------------------------------------------------------
2 ; crt0.s - Generic crt0.s for a Z80
4 ; Copyright (C) 2000, Michael Hope
6 ; This library is free software; you can redistribute it and/or modify it
7 ; under the terms of the GNU General Public License as published by the
8 ; Free Software Foundation; either version 2, or (at your option) any
9 ; later version.
11 ; This library is distributed in the hope that it will be useful,
12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ; GNU General Public License for more details.
16 ; You should have received a copy of the GNU General Public License
17 ; along with this library; see the file COPYING. If not, write to the
18 ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
19 ; MA 02110-1301, USA.
21 ; As a special exception, if you link this library with other files,
22 ; some of which are compiled with SDCC, to produce an executable,
23 ; this library does not by itself cause the resulting executable to
24 ; be covered by the GNU General Public License. This exception does
25 ; not however invalidate any other reasons why the executable file
26 ; might be covered by the GNU General Public License.
27 ;--------------------------------------------------------------------------
29 .module crt0
30 .globl _main
32 .area _HEADER (ABS)
33 ;; Reset vector
34 .org 0
35 jp init
37 .org 0x08
39 reti
40 .org 0x10
42 reti
43 .org 0x18
45 reti
46 .org 0x20
48 reti
49 .org 0x28
51 reti
52 .org 0x30
54 reti
55 .org 0x38
56 push af
57 ld a, #0x89
58 out (0x01), a
59 in a, (0x00)
60 push bc
61 push de
62 push hl
63 push iy
64 call _tick
65 pop iy
66 pop hl
67 pop de
68 pop bc
69 pop af
71 reti
73 .org 0x100
74 init:
75 ;; Set stack pointer directly above top of memory.
76 ld sp,#0x0000
78 ;; Initialise global variables
79 call gsinit
80 call _main
81 jp _exit
83 ;; Ordering of segments for the linker.
84 .area _HOME
85 .area _CODE
86 .area _INITIALIZER
87 .area _GSINIT
88 .area _GSFINAL
90 .area _DATA
91 .area _INITIALIZED
92 .area _BSEG
93 .area _BSS
94 .area _HEAP
96 .area _CODE
97 __clock::
98 ld a,#2
99 rst 0x08
102 _exit::
103 ;; Exit - special code to the emulator
104 ld a,#0
105 rst 0x08
107 halt
108 jr 1$
110 .area _GSINIT
111 gsinit::
113 ; Default-initialized global variables.
114 ld bc, #l__DATA
115 ld a, b
116 or a, c
117 jr Z, zeroed_data
118 ld hl, #s__DATA
119 ld (hl), #0x00
120 dec bc
121 ld a, b
122 or a, c
123 jr Z, zeroed_data
124 ld e, l
125 ld d, h
126 inc de
127 ldir
128 zeroed_data:
130 ; Explicitly initialized global variables.
131 ld bc, #l__INITIALIZER
132 ld a, b
133 or a, c
134 jr Z, gsinit_next
135 ld de, #s__INITIALIZED
136 ld hl, #s__INITIALIZER
137 ldir
139 gsinit_next:
141 .area _GSFINAL