Here's my boot code and IPL code... Not very great, as this was my first real attempt at ASM and boot code development...
Anyone can do what they want with it.
WARNING: This code performs low-level floppy and boot operations. Use with caution. I am NOT responsible for any stupid things you do!
; My first ASM program in Linux.
; Use an offset of 0 for the compiler
[ORG 0]
jmp 07c0h:start ; goto segment 7c00
start:
;Update segment registers
mov ax,cs
mov ds,ax
mov es,ax
reset:
; Acquire the floppy drive.
mov ax,0
mov dl,0 ; drive 0 (a drive)
int 13h
jc reset ; error => reset again
read:
; Ok. Read sectors 2-6 from the floppy. This is our IPL
mov ax,1000h ; es:bx = 1000:0000
mov es,ax
mov bx,0
mov ah,2 ; load disk data into es:bx
mov al,5 ; 5 sectors worth
mov ch,0 ; cylinder=0
mov cl,2 ; sector=2
mov dh,0 ; head=0
mov dl,0 ; drive = 0
int 13h ; read from drive
jc read ; error => try again
jmp 1000h:0000 ; jmp and execute program
times 510-($-$$) db 0
dw 0AA55h
IPL (Intermediate Program Loader)
;Update segment registers
mov ax,cs
mov ds,ax
mov es,ax
message db 'Hello! My OS!',0
mov si, message ; get our hello message
print:
lodsb
cmp al,0 ; Test if the current character is 0 (end)
je hang
mov ah,0eh ; Put Character
mov bx,7 ; Attribute
int 10h ; Call BIOS Video routine
jmp print
hang:
jmp hang ; Just hang around!
All it does (ready?) is display "Hello! My OS!". Oooh... Ahhhh...