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
|
#include <zeta.h>
.module crt0
.globl _main
.area _HEADER (ABS)
;; Reset vector
.org 0x0000
ld sp, #0x00
xor a
ld i, a
jp init
;; ISR table
.org 0x0010
_ctc0_isr_ptr:
.dw #0
_ctc1_isr_ptr:
.dw #0
_ctc2_isr_ptr:
.dw #0
.globl _ctc3_isr_ptr
_ctc3_isr_ptr:
.dw #_ctc3_isr
.globl _rx_isr_ptr
_rx_isr_ptr:
.dw #_rx_isr
;; Init code
init:
;; Configure banking
ld a, #0x81
out (MMU_A), A
ld a, #0x82
out (MMU_B), A
;; Disable PIO interrupts
ld a, #0x07
out (PORT_A_CTRL), a
ld a, #0x07
out (PORT_B_CTRL), a
call gsinit
call _main
1$:
halt
jr 1$
;; Ordering of segments for the linker.
.area _HOME
.area _CODE
.area _INITIALIZER
.area _GSINIT
.area _GSFINAL
.area _DATA
.area _INITIALIZED
.area _BSEG
.area _BSS
.area _HEAP
.area _CODE
.area _GSINIT
gsinit:
;; Default-initialized global variables.
ld bc, #l__DATA
ld a, b
or a, c
jr Z, zeroed_data
ld hl, #s__DATA
ld (hl), #0x00
dec bc
ld a, b
or a, c
jr Z, zeroed_data
ld e, l
ld d, h
inc de
ldir
zeroed_data:
;; Explicitly initialized global variables.
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
|