Home > categories > Machinery & Equipment > Loaders > Could someone give me source code for an assembly boot loader that opens a certain file at start?
Question:

Could someone give me source code for an assembly boot loader that opens a certain file at start?

10 points to best answer!

Answer:

You need to provide more information. A file system is an abstract concept invented by humans, hard disks do not directly support files. They are merely a commondity provided by the OS: specific bit patterns are interpreted in a specific way. A boot loader would need to implement support for a file system from scratch. What file system are you interested in?
I'll leave out you at the same time you are long gone. Remember, it is not good-bye it is See ya later :D Good success to you and God bless you. I gave you a celebrity for success and likewise for you are bravery.
Your best bet is probably to look at the various boot loaders for Linux, and pick one of them as a starting point. They are all open source:
Okay, perhaps I didn't explain well enough. Here's how things work: Languages such as C provide a standard library that lets you deal with files. Suppose you want to write to a file. What this standard library actually does is ask the operating system to write to that file. The operating system will ask the file system driver for that particular volume to handle the operation. The file system driver interprets a map (a data structure specific to the file system - FAT is different from NTFS for instance) at the beginning of the volume which tells it where a file starts on the hard disk and where it ends (this is very simplified, mind you - it does not even take fragmentation into account) and then modifies it. Since you do not have such a driver, you cannot open a file. What you want to do is to interpret the map in order to know where to look on the hard disk for the actual file. Again, a file is nothing physical, it's just a human convention. This is similar to an old music tape; the stereo has no idea where a song begins and where it ends. You cannot ask the computer to open a file. What you need to look into is: a file system specification (I recommend FAT because it's one of the more simple ones) and BIOS services for reading sectors off the disk. It is uncommon for boot loaders to use storage drivers so they usually use the BIOS to read. The operating system however does not do the same. The BIOS services you care about are the conventional INT 13h functions and EDD (Enhanced Disk Drive) - virtually all modern computers support the latter so you might not care about the conventional functions anymore; it depends on what your goals are. PS: I have taken the liberty to assume that this is a PC-compatible machine with a BIOS firmware.

Share to: