forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.asm
executable file
路106 lines (85 loc) 路 1.43 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
94
95
96
97
98
99
100
101
102
103
104
105
106
; asmsyntax=nasm
[org 0x7c00]
[bits 16]
boot:
push cs
pop ds
xor bx, bx
mov ah, 0x0e
mov si, message
lodsb
.lewp:
int 0x10
lodsb
cmp al, 0
jne .lewp
mov bx, 0x1000
mov es, bx
xor bx, bx ; Load kernel @ 0x10000
mov ah, 0x02 ; cmd 0x02 - Read Disk Sectors
mov al, 72 ; 72 sectors (max allowed by bochs BIOS)
mov ch, 0 ; track 0
mov cl, 10 ; sector 10
mov dh, 0 ; head 0
mov dl, 0 ; drive 0 (fd0)
int 0x13
jc fug
mov ah, 0x02
mov al, 32
add bx, 0x9000
mov ch, 2
mov cl, 10
mov dh, 0
mov dl, 0
int 0x13
jc fug
lgdt [cs:test_gdt_ptr]
mov eax, cr0
or al, 1
mov cr0, eax
jmp 0x08:pmode
pmode:
[bits 32]
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov esp, 0x2000
jmp 0x10000
hlt
test_gdt_ptr:
dw (test_gdt_end-test_gdt)
dd test_gdt
test_gdt:
dd 0
dd 0
dd 0x0000ffff
dd 0x00cf9a00
dd 0x0000ffff
dd 0x00cf9200
dd 0
dd 0
dd 0
dd 0
test_gdt_end:
[bits 16]
fug:
xor bx, bx
mov ah, 0x0e
mov si, fug_message
lodsb
.lewp:
int 0x10
lodsb
cmp al, 0
jne .lewp
cli
hlt
message:
db "boot!", 0x0d, 0x0a, 0
fug_message:
db "FUG!", 0x0d, 0x0a, 0
times 510-($-$$) db 0
dw 0xaa55