Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
I am using Neon's tutorials at brokenthorn, and I have just finished the Bootloader tutorial. I have a FAT system setup. I was going to pause from doing the tutorials and do a little work myself. I am just trying to load a text file and add two numbers from seperate lines inside and add them together. An example text file would be:
By setup, I mean that I can search for and run a second stage in the form of a .sys file. I just do not know how to open a file and read from its contents.
Read the tutorials at http://www.Brokenthorn.com. There they go over the basics. The load a stage 1 bootloader which loads a stage 2 (which is saved as a .sys) and even load and run a C kernel (might be a c++ kernel) Not to mention they go over other basics like pmode, 32-bit, and other stuff that one might want.
The FAT12 code can be used to load a file of any type. Text files have no real specific format (Besides the EOF character, and parsing special characters like new lines)
I personally recommend waiting until the Stage 2 bootloader, as the first stage is limited to 512 bytes.
Once the image is in memory, then parse it line by line and go from there...
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
neon wrote:The FAT12 code can be used to load a file of any type. Text files have no real specific format (Besides the EOF character, and parsing special characters like new lines)
I personally recommend waiting until the Stage 2 bootloader, as the first stage is limited to 512 bytes.
Once the image is in memory, then parse it line by line and go from there...
My loader loads a file from a FAT12-volume without the need for non-fragmented systemfiles, support for both int 13h extensions and legacy int 13h functions, and no precalculated-sectors. It's a hard job to put that in 512 bytes, but it's possible. But before you even begin with an OS, learn the basics.
But it can only load the most necessary binary file for further loading the OS. Reading and parsing textfiles cannot be done from a small bootsector, waith until "stage 2" or whatever you call it.
OK, I think I can put it in Stage two, I just need to get the FAT12 search code copied over. Will the FAT tables stay in memory after being loaded to run the second stage?
Yes - as long as you are certain that no other code / data has overwritten them (in other words, be careful that no other buffers overlap these areas).