Code: Select all
%macro outb 2
mov dx, %1
mov al, %2
out dx, al
%endmacro
%macro inb 2
mov dx, %1
in al, dx
mov %2, al
%endmacro
[bits 32]
section .text
extern bootloader
extern disk_error
extern kernel_not_loaded_error
global load_kernel_test
load_kernel_test:
mov byte [0x2000], 0xEB
mov byte [0x2001], 0xFE
mov byte [0x2002], 0x00
mov byte [0x2003], 0x00
ret
global load_kernel
load_kernel:
outb 0x1F6, 0xA0
outb 0x1F2, 1
outb 0x1F3, 0x00
outb 0x1F4, 0x49
outb 0x1F5, 0x00
outb 0x1F7, 0x20
inb 0x1F7, al
test al, 0x40
jz .take_a_nap
mov edi, kernel_start
.read_loop:
inb 0x1F0, al
stosb
inb 0x1F7, al
test al, 0x40
jz .read_loop
inb 0x1F7, al
test al, 0x01
jnz .error_occured
.take_a_nap:
sub edi, kernel_start
ret
.error_occured:
call disk_error
ret
global call_kernel
call_kernel:
jmp kernel_start
ret
global check_kernel
check_kernel:
cmp byte [kernel_start], 0xEB
jne kernel_not_loaded_error
jmp call_kernel
section .rodata:
kernel_start equ 0x2000
Code: Select all
cpu: count=2, reset_on_triple_fault=0
display_library: x, options="gui_debug"
megs: 512
clock: sync=realtime, time0=local
ata0-master: type=disk, path="build/floppy.img", mode=flat
boot: c
log: ./bochsout.txt
mouse: enabled=0
magic_break: enabled=1