Question about FAT12
Posted: Mon Oct 24, 2005 2:07 am
Hi everyone,
Ok, I have been on and off playing around with creating my own OS, I am trying to understand how FAT12 works but something doesn't seem right, I am pretty sure I am missing something, but I just want some clarification so that I understand it properly.
The numbers below represent the first 10 bytes of the FAT organized into their 12 bit entries, so 001 is FAT(0), 122 is FAT(1), etc...
001 122 334 455 667 788 99
If I look at a directory entry and get a first cluster number of 2 then I first read the corresponding cluster, this is fine, I understand this but when it comes to getting the next cluster number from the FAT I don't understand something, I will explain that now.
The process to get the next cluster number is as follows:
EntryLocation = (ClusterNumber / 2) + ClusterNumber
Viewing the FAT as an array of bytes I would read a word, the word I would read is in italics in the above numbers
word FatEntry = FAT[EntryLocation]
now I have to adjust this value to get the 12 bits I am after, here is the problem:
If ClusterNumber is even, I am supposed to clear the highest nibble which would leave me with 344, but a ClusterNumber of 2 means I should end up with 334... It seems to me that I should be shifting FatEntry right 4 bits if its even and clear the high 4 bits if its odd which is opposite to what the documentation says...
I hope you can understand this post, I am really confused about this ???
Cheers.
Ok, I have been on and off playing around with creating my own OS, I am trying to understand how FAT12 works but something doesn't seem right, I am pretty sure I am missing something, but I just want some clarification so that I understand it properly.
The numbers below represent the first 10 bytes of the FAT organized into their 12 bit entries, so 001 is FAT(0), 122 is FAT(1), etc...
001 122 334 455 667 788 99
If I look at a directory entry and get a first cluster number of 2 then I first read the corresponding cluster, this is fine, I understand this but when it comes to getting the next cluster number from the FAT I don't understand something, I will explain that now.
The process to get the next cluster number is as follows:
EntryLocation = (ClusterNumber / 2) + ClusterNumber
Viewing the FAT as an array of bytes I would read a word, the word I would read is in italics in the above numbers
word FatEntry = FAT[EntryLocation]
now I have to adjust this value to get the 12 bits I am after, here is the problem:
If ClusterNumber is even, I am supposed to clear the highest nibble which would leave me with 344, but a ClusterNumber of 2 means I should end up with 334... It seems to me that I should be shifting FatEntry right 4 bits if its even and clear the high 4 bits if its odd which is opposite to what the documentation says...
I hope you can understand this post, I am really confused about this ???
Cheers.