Code: Select all
section .text
use16
org 0x7C00 ; Load addr
start:
mov ax, cs
mov ds, ax ; Select data segment.
mov ah, 1 ; Turn on the cursor.
int 0x10
mov ah, 00h ; Set video mode.
mov al, 2
int 0x10
mov ah, 13h ; Notify about booloader start.
mov al, 1
mov bh, 0
mov bl, 0_7h
mov cx, start_msg_len
mov dh, 0
mov dl, 0
mov bp, start_msg
int 0x10
mov bl, 0_2h ; Write welcome message.
mov dl, start_msg_len + 1
mov cx, welcome_msg_len
mov bp, welcome_msg
int 0x10
mov bl, 0_7h ; Notify about next stage loading.
mov dh, 2
mov dl, 0
mov cx, load_kern_msg_len
mov bp, load_kern_msg
int 0x10
mov ah, 0 ; Let's reset floppy's controller!
mov dl, 0
int 0x13
jc error
mov ah, 2
mov al, 1
mov ch, 1
mov cl, 1
mov dh, 1
mov ebx, 0x1000
mov dl, 0
int 0x13
jc error
jmp 0x1000
hlt
start_msg db "SimpleX bootloader started."
start_msg_len equ $ - start_msg
welcome_msg db "Welcome!"
welcome_msg_len equ $ - welcome_msg
load_kern_msg db "Loading next stage..."
load_kern_msg_len equ $ - load_kern_msg
error:
mov ah, 00h
mov al, 2
int 0x10
mov ah, 13h
mov al, 1
mov bh, 0
mov bl, 0_4h
mov cx, error_msg_len
mov dh, 0
mov dl, 0
mov bp, error_msg
int 0x10
hlt
error_msg db "Critical error occured! Cannot continue."
error_msg_len equ $ - error_msg
finish:
times 0x1FE-finish+start db 0
db 0x55, 0xAA ; Boot signature