-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootloader.asm
More file actions
62 lines (50 loc) · 994 Bytes
/
bootloader.asm
File metadata and controls
62 lines (50 loc) · 994 Bytes
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
BITS 16
org 0x7c00
jmp start
; FAT headers stops at 3e
times 0x3e - ( $ - $$ ) db 0
bootdrive: db 0
start:
; store bootdrive for later
mov [bootdrive], dl
; clear direction flag
cld
; set up hardware stack
xor ax, ax
mov es, ax
mov ss, ax
mov ds, ax
mov sp, ax
; load kernel
mov ah, 0x02
mov al, 59 ; 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, 3 ; sector count
mov ch, 0 ; cylinder
mov cl, 61 ; sector
mov dh, 0 ; head
; dl = boot drive
mov bx, 0x7e00 ; destination address
int 0x13
mov ah, 0x02
mov al, 60 ; sector count
mov ch, 0 ; cylinder
mov cl, 1 ; sector
mov dh, 1 ; head
; dl = boot drive
add bx, 512*3 ; destination address
int 0x13
; clear screen
mov ax, 0x0003 ; 80x25 16 color text
int 0x10
jmp 0:0x0500 ; goto: kernel
; magic numbers
times 510 - ( $ - $$ ) db 0
db 0x55, 0xaa