forked from EtchedPixels/FUZIX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrt0.s
97 lines (84 loc) · 2.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
95
96
; Ordering of segments for the linker.
; WRS: Note we list all our segments here, even though
; we don't use them all, because their ordering is set
; when they are first seen.
.area _BOOT
.area _CODE
.area _CODE2
.area _VIDEO
.area _CONST
.area _DATA
.area _INITIALIZED
.area _BSEG
.area _BSS
.area _HEAP
; note that areas below here may be overwritten by the heap at runtime, so
; put initialisation stuff in here
.area _INITIALIZER
.area _GSINIT
.area _GSFINAL
.area _COMMONMEM
.area _DISCARD
; imported symbols
.globl _fuzix_main
.globl init_early
.globl init_hardware
.globl s__DATA
.globl l__DATA
.globl s__DISCARD
.globl l__DISCARD
.globl s__COMMONMEM
.globl l__COMMONMEM
.globl s__INITIALIZER
.globl kstack_top
; Just for the benefit of the map file
.globl start
.globl enaslt
.globl slotram
.globl find_ram
; startup code @0x100
.area _CODE
;
; Execution begins with us correctly mapped and at 0x0x100
;
; We assume here that the kernel packs below 48K for now we've got a few
; KBytes free but revisit as needed
;
.ds 0x100
start:
di
; Debug port
ld a, #0x23
out (0x2e), a
ld a, #'@'
out (0x2f), a
; read slot before switching ram page
ld a,(slotram)
ld hl,#0x4000
call enaslt
ld a, #4 ; 0 holds 8K of stuff we might want
out (0xff), a ; if we go the OS route, so use 4
; plus "0" is magic so this saves
; shifting them all by one.
ld sp, #kstack_top
; move the common memory where it belongs
ld hl, #s__INITIALIZER
ld de, #s__COMMONMEM
ld bc, #l__COMMONMEM
ldir
; move the discardable memory where it belongs
ld de, #s__DISCARD
ld bc, #l__DISCARD
ldir
; then zero the data area
ld hl, #s__DATA
ld de, #s__DATA + 1
ld bc, #l__DATA - 1
ld (hl), #0
ldir
call init_early
call init_hardware
call _fuzix_main
di
stop: halt
jr stop