77 lines
1.8 KiB
NASM
Executable File
77 lines
1.8 KiB
NASM
Executable File
org 0x7C00 ; set up start address
|
|
|
|
; setup a stack
|
|
mov ax, 0x9000 ; address of the stack SS:SP
|
|
mov ss, ax ; SS = 0x9000 (stack segment)
|
|
xor sp, sp ; SP = 0x0000 (stack pointer)
|
|
|
|
; start
|
|
mov [bootdrive], dl ; boot drive from DL
|
|
call load_kernel ; load kernel
|
|
|
|
; jump to kernel
|
|
jmp 0x1000:0x0000 ; address of kernel
|
|
|
|
bootdrive db 0 ; boot drive
|
|
loadmsg db "loading kernel ...",0
|
|
|
|
; print string
|
|
print_string:
|
|
lodsb ; grab a byte from SI
|
|
or al, al ; NUL?
|
|
jz .done ; if the result is zero, get out
|
|
mov ah, 0x0E
|
|
int 0x10 ; otherwise, print out the character!
|
|
jmp print_string
|
|
.done:
|
|
ret
|
|
|
|
|
|
; read kernel from floppy disk
|
|
load_kernel:
|
|
|
|
mov dh, 10 ;row
|
|
mov dl, 28 ;colum
|
|
mov bh, 0 ;page
|
|
mov ah, 2 ;interupt selection
|
|
int 10h ;coursor to middle
|
|
|
|
;hide coursor
|
|
mov ch, 32
|
|
mov ah, 1
|
|
int 10h
|
|
|
|
|
|
mov si,loadmsg
|
|
call print_string ;welcome message
|
|
|
|
MOV CX, 0FH
|
|
MOV DX, 4240H
|
|
MOV AH, 86H
|
|
INT 15H;wait interupt
|
|
|
|
mov dl,[bootdrive] ; select boot drive
|
|
xor ax, ax ; mov ax, 0 => function "reset"
|
|
int 0x13
|
|
jc load_kernel ; trouble? try again
|
|
|
|
load_kernel1:
|
|
mov ax, 0x1000
|
|
mov es, ax ; ES:BX = 0x10000
|
|
xor bx, bx ; mov bx, 0
|
|
|
|
; set parameters for reading function
|
|
; 8-Bit-wise for better overview
|
|
mov dl,[bootdrive] ; select boot drive
|
|
mov al,10 ; read 10 sectors
|
|
mov ch, 0 ; cylinder = 0
|
|
mov cl, 2 ; sector = 2
|
|
mov dh, 0 ; head = 0
|
|
mov ah, 2 ; function "read"
|
|
int 0x13
|
|
jc load_kernel1 ; trouble? try again
|
|
ret
|
|
|
|
times 510-($-$$) hlt
|
|
db 0x55
|
|
db 0xAA |