When a computer is powered off, it is essentially 'brain dead.' Once the power button is depressed, the machine has to go from knowing nothing to loading a functional operating system into its memory. A process known as bootstrapping takes the computer from the hardware BIOS to some program that can then load an operating system. Matthew Vea walks us through the process for x86-based systems and in addition provides us with some bootstrapping code in this informative article.
It is a good article and found helpful one. But I am wondering on the formula given to calculate absolute sector whether it is
absolute sector = (logical sector / sectors per track) + 1
or
absolute sector = (logical sector MOD sectors per track) + 1
also i am going through your code but i got stuck a point. in very start of code we have lines
mov bx,0x0200
call readsectors
but these lines came again after 10 lines. can you help me out whats going on.
ReadSectors is used in the code to perform three different operations (hence why you see it multiple times). The first time is to read the root directory. Under FAT12, the root directory is in the same location ALL the time so it's possible to look directly at it. This is to determine where the starting point of the file we intend to load is. The second time ReadSectors is called is to read the FAT (file allocation table) and use that index to determine where physically on the disk the file is located. The third (and subsequent) time(s) ReadSectors is called is during the disk reading loop, where the code will read every sector that file resides on and load the image into memory for execution.
I still haven't had a chance to work on a FAT32 update. Although I did dig out my old FAT32 documents over the weekend.
The article correctly mentions the importance of setting up segment registers, yet like most neglects to set up CS (which is 0x0000). This is one nasty latent bug that shows itself as soon as you try doing indirect jumps. So if you want to use something like threaded code in your first stage bootloader set CS by "jmp 0x07c0:foo" first.



article
by 
Add a Comment (8)
Email This
Message Author
Statistics
RSS


Comments on Slashdot by markmcb :: NR7 :: Show
Knowing that not all O-nerds have much interest in bootstrapping, I thought I'd post a link to a discussion going on at Slashdot about this article.