Page 1 of 1

FAT12 FAT question

Posted: Tue Dec 16, 2008 1:56 pm
by renovatio
Hello. I'm writting a FAT12 load file function. Up to now I could load a 512 byte file. But to load a bigger file, I have to use the FAT. I read many bootsectors and FAT12 specifications, and have some questions:

This is a table I made:

Code: Select all

87654321 87654321 87654321 87654321
[     1     ]
             [     2     ]
[       3       ] [       4       ]

1: The First Cluster
2: The Second Cluster
3: The First Word
4: The Second Word
[/size]

I read that if I load the first word, I get the whole first cluster and a part of the second, which is correct. But I also read that if I load the second word, I get a part of the first and the whole second cluster. My table shows that I get only a part of the second cluster and a part of the third cluster. Really I don't understand.

Thank you :)

Re: FAT12 FAT question

Posted: Tue Dec 16, 2008 2:45 pm
by Firestryke31
Here's how I understand how FAT12 works:

The first whole byte, and the upper 4 bits of the second byte contain the first cluster, while the lower 4 bits of the second byte and the third whole byte contains the second cluster. The third cluster starts over on a whole byte, and the fourth is just like the second.

Code: Select all

0x11 0x12 0x22
0x33 0x34 0x44

1 = first cluster
2 = second cluster
3 = third cluster
4 = fourth cluster
So, basically, odd clusters start on byte boundaries, and even clusters start halfway through the next byte.

Someone else could confirm this, because I might have gotten the ordering of the middle byte backwards...