basic os stuff
This commit is contained in:
70
boot.asm
Normal file
70
boot.asm
Normal file
@@ -0,0 +1,70 @@
|
||||
[BITS 16]
|
||||
[ORG 0x7C00]
|
||||
|
||||
KERNEL_SEGMENT equ 0x1000
|
||||
KERNEL_SECTORS equ 32
|
||||
boot:
|
||||
jmp 0x0000: .init
|
||||
.init:
|
||||
cli
|
||||
xor ax,ax
|
||||
mov ds,ax
|
||||
mov es, ax
|
||||
mov ss, ax
|
||||
mov sp, 0x7C00
|
||||
sti
|
||||
|
||||
mov [boot_drive], dl
|
||||
xor ax,ax
|
||||
int 0x13
|
||||
|
||||
jc .disk_error
|
||||
|
||||
call load_kernel
|
||||
|
||||
mov ax, KERNEL_SEGMENT
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
jmp KERNEL_SEGMENT:0x0000
|
||||
|
||||
.disk_error:
|
||||
mov si, disk_err
|
||||
call print_str
|
||||
cli
|
||||
hlt
|
||||
load_kernel:
|
||||
mov ax, KERNEL_SEGMENT
|
||||
mov es,ax
|
||||
xor bx, bx
|
||||
|
||||
mov ah, 0x02
|
||||
mov al, KERNEL_SECTORS
|
||||
mov ch, 0
|
||||
mov cl, 2
|
||||
mov dh, 0
|
||||
mov dl, [boot_drive]
|
||||
int 0x13
|
||||
jc .disk_error
|
||||
ret
|
||||
.disk_error:
|
||||
mov si, disk_err
|
||||
call print_str
|
||||
cli
|
||||
hlt
|
||||
|
||||
|
||||
print_str:
|
||||
lodsb
|
||||
or al, al
|
||||
jz .done
|
||||
mov ah, 0x0E
|
||||
int 0x10
|
||||
jmp print_str
|
||||
.done:
|
||||
ret
|
||||
|
||||
boot_drive: db 0
|
||||
disk_err: db "Disk error", 0x0D, 0X0A, 0
|
||||
times 510 - ($-$$) db 0
|
||||
dw 0xAA55
|
||||
Reference in New Issue
Block a user