aboutsummaryrefslogtreecommitdiff
path: root/crt0.s
blob: 37c5fae8e16473276460ce3c5ed517af7fc68cd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
.module crt0
.globl	_main
.globl _main_init

	.area	_HOME
	.area	_CODE
	.area	_INITIALIZER
    .area   _GSINIT
    .area   _GSFINAL

	.area	_DATA
	.area	_INITIALIZED
	.area	_BSEG
    .area   _BSS
    .area   _HEAP

   	.area   _CODE

_main_init::

	di
	; disable the firmware
	ld hl, #0x38
	ld (hl), #0xfb
	inc hl
	ld (hl), #0xc9

	; disable upper/lower roms
	ld bc, #0x7f8c
	out (c), c

	; put the stack as high as we can
	ld sp, #0xc000
	ei

	call gsinit
	call _main

halt0:
    halt
    jr halt0

	.area   _GSINIT
gsinit::
	ld bc, #l__INITIALIZER
	ld a, b
	or a, c
	jr Z, gsinit_next
	ld de, #s__INITIALIZED
	ld hl, #s__INITIALIZER
	ldir
gsinit_next:

.area   _GSFINAL
   	ret