/
crt0_rom32.asm
82 lines (69 loc) · 2.03 KB
/
crt0_rom32.asm
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
; ___________________________
; ██▀█▀██▀▀▀█▀▀█▀█ ▄▄▄ ▄▄ │ ▄▄ ▄▄ ▄▄
; █ ▄ █▄ ▀██▄ ▀▄█ ██ ██ │ ██ ▀ ██▄▀ ██▀ █ ██
; █ █ █▀▀ ▄█ █ █ ▀█▄█ ██▄▄ │ ▀█▄▀ ██ ▀█▄ ▀▄█▀
; ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀───────────┘
;------------------------------------------------------------------------------
; crt0 header for 32KB ROM program
;------------------------------------------------------------------------------
; By Guillaume 'Aoineko' Blanchard for MSX Game Library
; (ɔ) 2022 under CC-BY-AS license
;------------------------------------------------------------------------------
; Code address: 0x4010 (right after the header)
; Data address: 0xC000
;------------------------------------------------------------------------------
.module crt0
.include "defines.asm"
.include "macros.asm"
HIMEM = #0xFC4A
;------------------------------------------------------------------------------
.area _HEADER (ABS)
.org 0x4000
_g_FirstAddr::
_g_HeaderAddr::
; ROM header
.db 0x41 ; A
.db 0x42 ; B
.dw crt0_init
.dw 0x0000
.dw 0x0000
.dw 0x0000
.dw 0x0000
.dw 0x0000
.dw 0x0000
;------------------------------------------------------------------------------
.area _CODE
crt0_init:
di
; Set stack address at the top of free memory
ld sp, (HIMEM)
; Initialize heap address
ld hl, #s__HEAP
ld (#_g_HeapStartAddress), hl
; Set Page 2 slot equal to Page 1 slot
INIT_P1_TO_P2
; Initialize globals
INIT_GLOBALS
crt0_start:
; start main() function
ei
call _main
rst 0
;------------------------------------------------------------------------------
; Ordering of segments for the linker
;-- ROM --
.area _HOME
.area _CODE
.area _RODATA
.area _INITIALIZER
.area _GSINIT
.area _GSFINAL
_g_LastAddr::
;-- RAM --
.area _DATA
_g_HeapStartAddress::
.ds 2
.area _INITIALIZED
.area _BSEG
.area _BSS
.area _HEAP