FAT12 FAT question

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
renovatio
Member
Member
Posts: 57
Joined: Fri May 23, 2008 5:13 am

FAT12 FAT question

Post 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 :)
User avatar
Firestryke31
Member
Member
Posts: 550
Joined: Sat Nov 29, 2008 1:07 pm
Location: Throw a dart at central Texas
Contact:

Re: FAT12 FAT question

Post 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...
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
Post Reply