-
Notifications
You must be signed in to change notification settings - Fork 0
/
crt0.s
64 lines (53 loc) · 1.08 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
;///////////////////////////////////////////////////////////////////////////////
;// Copyright Christopher Kormanyos 2024.
;// Distributed under The Unlicense
;//
; crt0.s
; Perform C-runtime startup static initialization
; including the RAM classes of bss/data clear/init.
; RAM initialization is implemented in the subroutine gsinit.
; Subsequently jump to main() and never return.
.module crt
.globl _main
.area _HEADER (ABS)
.org #0x9D93
.dw #0x6DBB
call gsinit
jp _main
.org 0x9D9B
.area _CODE
.area _GSINIT
.area _GSFINAL
.area _DATA
.area _BSS
.area _INITIALIZED
.area _INITIALIZER
.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