forked from fox32-arch/fox32rom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.asm
93 lines (83 loc) · 1.88 KB
/
boot.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
83
84
85
86
87
88
89
90
91
92
93
; disk booting routines
; load the boot sector of disk 0 to 0x00000800 and jump to it
; inputs:
; none
; outputs:
; none (returns if disk 0 is not bootable)
start_boot_process:
; read sector 0 to 0x800
mov r0, 0
mov r1, 0
mov r2, 0x00000800
call read_sector
; check for the bootable magic bytes
cmp [0x000009FC], 0x523C334C
ifnz ret
; now clean up and jump to the loaded binary
call boot_cleanup
mov rsp, SYSTEM_STACK ; reset stack pointer
mov r0, 0 ; booting from disk id 0
jmp 0x00000800
; load the boot sector of the romdisk and jump to it
; inputs:
; none
; outputs:
; none (returns if romdisk is not bootable)
start_boot_process_from_romdisk:
; read sector 0 to 0x800
mov r0, 0
mov r1, 4
mov r2, 0x00000800
call read_sector
; check for the bootable magic bytes
cmp [0x000009FC], 0x523C334C
ifnz ret
; now clean up and jump to the loaded binary
call boot_cleanup
mov rsp, SYSTEM_STACK ; reset stack pointer
mov r0, 4 ; booting from disk id 4
jmp 0x00000800
; clean up the system's state before jumping to the loaded binary
; inputs:
; none
; outputs:
; none
boot_cleanup:
; clear the background
mov r0, BACKGROUND_COLOR
call fill_background
; disable the blinking disk icon
call cleanup_icon
movz.8 r0, 0
movz.8 r1, 0
movz.8 r2, 0
movz.8 r3, 0
movz.8 r4, 0
movz.8 r5, 0
movz.8 r6, 0
movz.8 r7, 0
movz.8 r8, 0
movz.8 r9, 0
movz.8 r10, 0
movz.8 r11, 0
movz.8 r12, 0
movz.8 r13, 0
movz.8 r14, 0
movz.8 r15, 0
movz.8 r16, 0
movz.8 r17, 0
movz.8 r18, 0
movz.8 r19, 0
movz.8 r20, 0
movz.8 r21, 0
movz.8 r22, 0
movz.8 r23, 0
movz.8 r24, 0
movz.8 r25, 0
movz.8 r26, 0
movz.8 r27, 0
movz.8 r28, 0
movz.8 r29, 0
movz.8 r30, 0
movz.8 r31, 0
ret