A bootsector is the first sector on the disk (head 0, cylinder 0)
which gets booted (when you start the computer),
the bios loads it into 0x0000:0x7c00
(memory)
Also called the mbr (Master Boot Recotr)
The mbr is 1 sector big (512 bytes usually)
bios-es check (well should do, a lot of new bioses do not (like mine) check the last 2 bytes for 0xAA55 to see if there is an bootsector on the disk, if not it checks another disk... or display an boot error..
This is a basic bootsector:
Code: Select all
org 7c00h
jmp main
main: jmp main
times 510-($-$$) db 0
sign dw 0xAA55
it should hang.
assemble like this:
Code: Select all
nasm bootsector.asm -f bin
dd if=bootsector of=/dev/disk
(if you're using win then it should be nasmw, and use partcopy or something for putting it on the disk)
To improve it a bit
Code: Select all
org 7c00h
jmp f
f: mov ah,0Eh
mov al,'f'
int 0x10
jmp main
main: jmp main
times 510-($-$$) db 0
sign dw 0xAA55
It now prints an f on the screen...
anyway the bootsector wasn't made for putting a lot of code in (I think
)
For an os, the bootsector should load the kernel code,
(if you're not using partitions =))
this can either be 16 bit or 32bit
(32bit means (pmode) you can access about 4 gigabyte of memory.
16bit means (realmode) you can maximum use 1 MB of memory)
Is suggest you load your kernel (if you're doing an os, using int 0x13) switch to pmode and jump to the kernel.
There are some pmode docs/questions on the board
(can't share mine code yet, don't know what license to put on it... bsl or gpl... or my own ....)
Best,
Frank