[ home | ideas | links | project | contact ]


Boot Sectors!

As you know, computers needs to be booted up using a BOOTABLE DISK. A typical computer disk is divided into portions known as tracks and sectors. It so happens that when the computer starts up, it reads the first sector of the disk into memory, and executes it. This first sector is known as a boot-sector. A boot-sector can be written in assembly language. Here is how:


.model tiny
.code

entry: ; we enter the program
jmp start ; required jump statement
nop ; nop required to follow the jmp
start:

;Add anything--put your code here

org 510
dw 0aa55h ; ; add signature of BOOT SECTOR
end entry

If you compile this in MASM, you'd get a 512 bytes long file.
You can write this file to the first sector of the disk using some utilities like John Fine's Partcopy. Then you can boot the computer using the disk.
Okay, just as a filler, be careful when you do a low-level write on any disk. It can screw you up real bad !

Remember, this is a Rough Guide!

You can easily add the 'Hello World' program given before to this boot-sector. You'd now have a boot-disk that says 'hello world' when it starts up! You might need more info to do other neat little things. For/p>

....now, the head is set to 0 again and cylinder is incremented

LBA# 37          cylinder 1 head 0 sector 1

one important point to keep in mind is that there is no sector 0, while there exist cylinder 0 and head 0.

In order to read or write a disk you must know what head, cylinder and sector to use. This creates problems with Linear Block Addressing (LBA). You can figure out what LBA numbers are if you look above. LBA is the  sequence number of Cylinder, Head, and Sector group (also called CHS).


<<<back