-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathboot.asm
More file actions
58 lines (50 loc) · 1.23 KB
/
boot.asm
File metadata and controls
58 lines (50 loc) · 1.23 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
[org 0x7C00]
entry: jmp 0x0000:.flushCS
.flushCS: ; Ensure CS is properly set
mov [BOOT_DRIVE], dl ; Store drive number
xor ax, ax
mov ss, ax
mov bp, entry ; Start stack under entrypoint
mov sp, bp
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
cld
;; Set text mode
sti
mov ah, 0x00
mov al, 0x12
int 0x10
cli
mov [VIDEO_MODE], ax
;; call clear_screen ; Clear the screen
;; Chainload the jump to 64 bit long mode to 512 after entry
mov bx, CHAINLOAD_ADDR
mov dh, 0x01 ; Number of sectors to read
mov dl, [BOOT_DRIVE]
mov cl, 0x02 ; First available sector
call disk_load
;; Chainload the kernel to KERNEL_ENTRY
mov bx, KERNEL_ENTRY
mov dh, 0x10 ; Number of sectors to read
mov dl, [BOOT_DRIVE]
mov cl, 0x03 ; First available sector
call disk_load
jmp longmode
jmp $
;;; Libraries
%include "BootLibrary/print.asm"
%include "BootLibrary/disk.asm"
;;; Data
KERNEL_ENTRY equ 0x1000
CHAINLOAD_ADDR equ 0x7E00
;; Mark Bootsector
times 507 - ($-$$) db 0
BOOT_DRIVE db 0
VIDEO_MODE dw 0
dw 0xAA55
%include "BootLibrary/longmode.asm"
;; Chainloaded sector
times 1024 - ($-$$) db 0
;; Kernel Here (Appended to binary)