-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootloader.asm
More file actions
59 lines (45 loc) · 958 Bytes
/
bootloader.asm
File metadata and controls
59 lines (45 loc) · 958 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
bits 16
org 0x7C00
_start:
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7C00
mov [boot_drive], dl
; clear screen
mov ax, 0x03
int 0x10
mov ah, 0x02 ; read sector function
mov al, 0x08 ; amount of sectors to read (SIZE / 512)
mov bx, 0x8000 ; Destination Offset
mov dh, 0x00 ; Head
mov dl, [boot_drive] ; BIOS drive number
mov ch, 0x00 ; Cylinder
mov cl, 0x02 ; start from sector specified (1-63)
int 0x13
jc fail
mov dl, [boot_drive]
jmp 0x0000:0x8000 ; jump to segment:offset
jmp $
fail:
mov ah, 0x0E
mov al, 'E'
int 0x10
mov ah, 0x0E
mov al, 'R'
int 0x10
mov ah, 0x0E
mov al, 'R'
int 0x10
mov ah, 0x0E
mov al, 'O'
int 0x10
mov ah, 0x0E
mov al, 'R'
int 0x10
hlt
jmp $
boot_drive db 0
times 510 - ($ - $$) db 0
dw 0xAA55