-
Notifications
You must be signed in to change notification settings - Fork 0
/
crt0.s
93 lines (74 loc) · 1.65 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
;; gdb monitor crt0.s for a Z80
.module crt0
.globl _main
.globl _sr
.area _HEADER (ABS)
;; Reset vector
.org 0
jp init
.org 0x08
push hl ;; RST 08, used for breakpoints
ld hl,#0x08 ;; 08 means a breakpoint was hit, pass it to sr routine
jp _sr ;; TODO maybe change to saveRegisters, semantics
.org 0x10
push hl
ld hl,#0x10
jp _sr
.org 0x18
push hl
ld hl,#0x18
jp _sr
.org 0x20
push hl
ld hl,#0x20
jp _sr
.org 0x28
push hl
ld hl,#0x28
jp _sr
.org 0x30
push hl
ld hl,#0x30
jp _sr
.org 0x38
jp 0x0b038
;;; NMI will be used for the 'bash' button
;;; If the user bashes this button, control will be given back to the
;;; monitor in order to resync with the debugger
.org 0x66
push hl
ld hl,#0x66
jp _sr
.org 0x100
init:
;; Stack at the top of memory.
;;; ld sp, #0xb000
ld sp, #0xb000
;; Initialise global variables
call gsinit
call _main
jp _exit
;; Ordering of segments for the linker.
.area _HOME
.area _CODE
.area _GSINIT
.area _GSFINAL
.area _DATA
.area _BSS
.area _HEAP
.area _CODE
__clock::
ld a,#2
rst 0x08
ret
_exit::
;; Exit - special code to the emulator
ld a,#0
rst 0x08
1$:
halt
jr 1$
.area _GSINIT
gsinit::
.area _GSFINAL
ret