-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot.asm
More file actions
102 lines (64 loc) · 1.29 KB
/
Copy pathboot.asm
File metadata and controls
102 lines (64 loc) · 1.29 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
[org 0x7C00]
bits 16
KERNEL_OFFSET equ 0x1000
KERNEL_SECTORS equ 50
start:
cli
mov [BOOT_DRIVE], dl
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7C00
mov si, boot_msg
call print_string
mov bx, KERNEL_OFFSET
mov dh, KERNEL_SECTORS
call load_kernel
jmp 0x0000:KERNEL_OFFSET
; =========================================
; LOAD KERNEL
; =========================================
load_kernel:
pusha
mov ax, 0x0000
mov es, ax
mov bx, KERNEL_OFFSET
mov ah, 0x02
mov al, KERNEL_SECTORS
mov ch, 0x00
mov cl, 0x02
mov dh, 0x00
mov dl, [BOOT_DRIVE]
int 0x13
jc disk_error
popa
ret
; =========================================
; DISK ERROR
; =========================================
disk_error:
mov si, error_msg
call print_string
jmp $
; =========================================
; PRINT STRING
; =========================================
print_string:
.next:
lodsb
or al, al
jz .done
mov ah, 0x0E
int 0x10
jmp .next
.done:
ret
; =========================================
; DATA
; =========================================
BOOT_DRIVE db 0
boot_msg db 'Loading NullOS...',0
error_msg db 'Disk Read Error!',0
times 510-($-$$) db 0
dw 0xAA55