-
Notifications
You must be signed in to change notification settings - Fork 0
/
crt0.s
94 lines (94 loc) · 1.13 KB
/
crt0.s
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
.module crt0
.globl _main
.globl _interruptCount
.globl _keyTarget
.globl _keyWait
.globl l__DATA
.globl s__DATA
.globl l__INITIALIZER
.globl s__INITIALIZER
.globl s__INITIALIZED
.globl _interruptHandler
.area _HEADER (ABS)
.org 0
; ld sp,#0xf300 ; stack location (single VRAM)
ld sp,#0xe700 ; stack location (double VRAM)
call gsinit
jr 0$
ret
0$:
ei
call _main
1$:
halt
jr 1$
.org 0x38
push af
exx
ld hl,#_interruptCount
inc (hl)
ld a,(_keyTarget)
sub (hl)
jr nz,6$
ld (_keyWait),a
6$:
ld hl,(_interruptHandler)
ld a,l
or h
jr z,4$
push ix
push iy
ld de,#5$
push de
jp (hl)
5$:
pop iy
pop ix
4$:
exx
pop af
ei
reti
.org 0x66
retn
;
.area _HOME
.area _CODE
.area _INITIALIZER
.area _GSINIT
.area _GSFINAL
.area _DATA
.area _INITIALIZED
.area _HEAP
.area _HEAP_END
;
.area _GSINIT
gsinit:
ld bc,#l__DATA
ld hl,#s__DATA
3$:
ld (hl),#0
inc hl
dec bc
ld a,c
or b
jr nz,3$
ld bc,#l__INITIALIZER
ld a,b
or a,c
jr z,2$
ld de,#s__INITIALIZED
ld hl,#s__INITIALIZER
ldir
2$:
.area _GSFINAL
ret
.area _DATA
_interruptHandler:
.ds 2
_interruptCount:
.ds 1
_keyTarget:
.ds 1
_keyWait:
.ds 1