What is OmniNerd?

Welcome! OmniNerd's content is generated by you, the reader. Through voting and moderation we strive to highlight the nerdiest of what's around and provide content that's a little more thought provoking than other sites.

Submit New Content

Voting Booth

Is it possible that in the distant future, President George W. Bush, the 43rd president, might be viewed as one of the greatest American Presidents?

41 votes, 6 comments
3
Nerd-Its
+ -

PC Bootstrap Loader Programming Tutorial in ASM

Layout article by VnutZ on 05 November 2005, tagged as computing, assembly language, programming, and tutorial

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.

Star This to Save in Your Profile Favorite
Thread parent sort order:
Highest Voted : Lowest Voted : Oldest : Newest
Thread verbosity:
Expand All : Minimize Replies to Comments
0 Nerd-Its - +
Comments on Slashdot by markmcb :: NR7

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.

0 Nerd-Its - +
Good Article by ramkrishna_cool :: NR0

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

0 Nerd-Its - +
Assistance with Code by VnutZ :: NR8

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.

0 Nerd-Its - +
CS register by Anonymous :: NR0

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.