-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot_hdd.asm
More file actions
94 lines (76 loc) · 1.77 KB
/
Copy pathboot_hdd.asm
File metadata and controls
94 lines (76 loc) · 1.77 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
BITS 16
CPU 8086
org 0x7c00
jmp start
; FAT headers stops at 3e
times 0x3e - ( $ - $$ ) db 0
bootdrive: db 0
; FLOPPY BOOT
; =============================================================
; 360KB 5.25" double density: 40 cylinders, 2 head, 9 sectors
; 1.2MB 5.25" high density: 80 cylinders, 2 head, 15 sectors
; 720KB 3.5" double density: 80 cylinders, 2 head, 9 sectors
; 1.44MB 3.5" high density: 80 cylinders, 2 head, 18 sectors
; =============================================================
; USB BOOT: 1023 cylinders, 16 head, 63 sectors
%define MAX_CYLINDER 1023
%define MAX_HEAD 16
%define MAX_SECTOR 63
start:
cld ; clear direction flag
mov [bootdrive], dl ; store bootdrive for later
; set up hardware stack
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, ax
mov ax, 0x0003 ; set video mode 80x25 color text
int 0x10
mov si, hello
call print
; load kernel
mov ah, 0x02
mov al, 17 ; sector count
mov ch, 0 ; cylinder
mov cl, 2 ; sector
mov dh, 0 ; head
; dl = boot drive
mov bx, 0x0500 ; destination address
int 0x13
; load source
mov ah, 0x02
mov al, 64 ; sector count
mov ch, 0 ; cylinder
mov cl, 19 ; sector
mov dh, 0 ; head
; dl = boot drive
mov bx, 0x7e00 ; destination address
int 0x13
; mov ah, 0x02
; mov al, 20 ; sector count
; mov ch, 1 ; cylinder
; mov cl, 1 ; sector
; mov dh, 1 ; head
; ; dl = boot drive
; add bx, 512*44 ; destination address
; int 0x13
jmp 0:0x0500 ; go to kernel
disk_error:
mov si, error
call print
jmp $
; print null-terminated string
; si = string address
print: lodsb
or al, al
jz .done
mov ah, 0x0e
int 0x10
jmp print
.done: ret
hello: db 'Loading...', 13, 10, 0
error: db 'Error loading disk.', 13, 10, 0
; magic numbers
times 510 - ( $ - $$ ) db 0
db 0x55, 0xaa