basic os stuff

This commit is contained in:
CScatgirl
2026-03-02 17:37:33 -05:00
commit e6231d46f2
7 changed files with 342 additions and 0 deletions

70
boot.asm Normal file
View 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