-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot.asm
More file actions
169 lines (133 loc) · 2.13 KB
/
boot.asm
File metadata and controls
169 lines (133 loc) · 2.13 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
[BITS 16]
[ORG 0x7C00]
BootDrive db 0
start:
cli
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7C00
mov [BootDrive], dl
mov ax, 0
mov ds, ax
mov es, ax
cld
call wc2boot
call load_kernel
call oscore
jmp $
print:
lodsb
cmp al, 0
je done
mov ah, 0x0E
mov bl, 0x7
int 0x10
jmp print
nl:
mov si, nltxt
call print
ret
done:
ret
KERNEL_SECTORS equ 16
load_kernel:
mov ax, 0x0000
mov es, ax
mov bx, 0x1000
mov ah, 0x02
mov al, KERNEL_SECTORS
mov ch, 0x00
mov cl, 0x02
mov dh, 0x00
mov dl, [BootDrive]
int 0x13
jc disk_error
ret
disk_error:
mov si, errtxt
call print
jmp $
errtxt db 'Disk read error',0
disable_cursor:
mov dx, 0x3D4
mov al, 0x0A
out dx, al
inc dx
mov al, 0x20
out dx, al
ret
wc2boot:
mov si, long1
call print
mov si, long1
call print
call nl
mov si, body1
call print
call nl
mov si, wctxt
call print
call nl
mov si, wctxt2a
call print
call nl
mov si, wctxt2b
call print
call nl
mov si, wctxt2c
call print
call nl
mov si, body1
call print
call nl
mov si, long1
call print
mov si, long1
call print
call nl
ret
align 8
gdt32b:
dq 0x0000000000000000
dq 0x00CF9A000000FFFF
dq 0x00CF92000000FFFF
gdt32bEnd:
gdt32bLoc:
dw gdt32bEnd - gdt32b - 1
dd gdt32b
oscore:
mov si, lchkrl
call print
call nl
call disable_cursor
cli
in al, 0x92
or al, 00000010b
out 0x92, al
lgdt [gdt32bLoc]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp 0x08:safeMode
wctxt db '# MiBoot16Bit #', 0
wctxt2a db '# If you want to #', 0
wctxt2b db '# use this os whow #', 0
wctxt2c db '# main, you are idiot #', 0
lchkrl db 'Loading core', 0
long1 db '############',0
body1 db '# #',0
nltxt db 0x0D, 0x0A, 0
[BITS 32]
safeMode:
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov esp, 0x90000
jmp 0x08:0x1000
times 510-($-$$) db 0
dw 0xAA55