Stage 1:
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, next_stg_msg_len
mov bp, next_stg_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, 0
mov cl, 1
mov dh, 0
mov ebx, 0x1000
mov dl, 0
int 0x13
jc error
jmp dword 0x1000
start_msg db "SimpleX bootloader started."
start_msg_len equ $ - start_msg
welcome_msg db "Welcome!"
welcome_msg_len equ $ - welcome_msg
next_stg_msg db "Loading next stage..."
next_stg_msg_len equ $ - next_stg_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
cli
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
Code: Select all
section .text
use16
org 0x7C00
start:
mov ax, cs
mov ds, ax ; Select data segment.
mov ah, 00h ; Set video mode.
mov al, 2
int 0x10
cli
hlt
finish:
times 0x1FE-finish+start db 0
Code: Select all
$ dd if=/dev/zero of=boot.img bs=1024 count=1440
$ dd if=stage1.bin of=boot.img conv=notrunc
$ dd if=stage2.bin of=boot.img conv=notrunc seek=512