FAT12 Implementation

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.
Post Reply
PlayOS

FAT12 Implementation

Post by PlayOS »

Hi all,

Just thought I would share this link with all you guys interested in it.

http://www.geocities.com/mvea/bootstrap.htm

The code at this site, is a simple implementation of the FAT12 file system, I have got it to work as is, in my boot sector, I am now going to optimize it a bit, maybe merge some of the functions together, anyway this is a good basis to learn from, and then implement your own.

I noticed a couple of threads on FAT12 so I just posted a new topic rather than going into all of them and replying.

Hope this helps someone.
jcout_bsi

Re:FAT12 Implementation

Post by jcout_bsi »

Nice ... thanx that helps alot!
richie

Re:FAT12 Implementation

Post by richie »

lo!
Your code looks good. I think a small optimation would be to use org 0x7C00. Then you would save the code you use for adjusting the segment registers.
Mr_Spam

Re:FAT12 Implementation

Post by Mr_Spam »

now e understand and have some examples of implementing fat12 in the root directory, what about searching for a file in another directory?
PlayOS

Re:FAT12 Implementation

Post by PlayOS »

Hi,

First off, this is not my code, I just found the site (Don't want anyone to think I am stealing credit here ;)).

To search for a directory, all you need to do is replace the filename with the directory name, and if you get a match you would then test the attributes of that entry and if it is a directory then you would need to load that directory into memory, the loading and searching would the same as for the root dir, except you would need to load the new directory from a different place. Starting at the cluster listed in the dir entry. The loading of a subdirectory is slightly different to the root in that you will need to follow a chain of clusters, with the root directory it is always in consecutive sectors and of a predetermined size.

It should be fairly simple to implement, you will need to do this from a second stage loader, because it would take more than 512 bytes - BPB to implement that.

Glad I could Help. Good Luck!
Mr_Spam

Re:FAT12 Implementation

Post by Mr_Spam »

when i copy his BPB into my source, compile then place it ont he boot sector of the floppy, the floppy cant be read by windows or linux. the file system type could not be determined. any help?
jrfritz

Re:FAT12 Implementation

Post by jrfritz »

Windows thinks the floppy is not fat...windows...windows...

because you over written some fat data...
Mr_Spam

Re:FAT12 Implementation

Post by Mr_Spam »

linux says the same
Mr_Spam

Re:FAT12 Implementation

Post by Mr_Spam »

i found the error,

jmp start
nop

{BPB}

start:

this is not formated while

jmp short start
nop

{BPB}

Start:

is formatted. why I have no idea. now when i write to the second sector of the disk, it losses its formatting again, any help?
Curufir

Re:FAT12 Implementation

Post by Curufir »

FAT format specifies a 3 byte instruction before the BPB. The first example here (The one that's broken) looks like it's using the far form of jump, plus a nop, which adds up to more than 3 bytes, which in turn would offset your BPB and make it unrecognisable to anything searching for FAT12.

This is odd though, because most assemblers I know of use the short form as default. It's very unusual to have to explicitly specify the short form.

**

In FAT12 the FATs occupy the sectors immediately following the bootsector (The next 18 sectors for 1.44mb floppy). The root directory then follows this. Screwing around with this area by dumping sectors into it is not going to help you maintain the integrity of the FS. The whole purpose of using FAT12 in a boot disk is so that you can load files, not prespecified sectors. Just copy the files onto the FAT12 disk and work from there.
Mr_Spam

Re:FAT12 Implementation

Post by Mr_Spam »

That was one of the first things i suspected when i started to debug. So i compiled just the first 2 commands in the first example, and yet the binary file was exactly 3 bytes, or so it said on my linux box. --wierd.

still have any idea why the disk becomes unformatted when writting to the second or third sector on the disk?
Post Reply