View previous topic :: View next topic |
Author |
Message |
nader
Joined: 29 Aug 2004 Posts: 12
|
determine the root directory sector |
Posted: Mon Mar 28, 2005 12:54 am |
|
|
hi,
i want to determine the count root directory sector &
i think i must count it as follow:
RootDirSectors = (BPB_RootEntCnt * 32) / BPB_BytsPerSec;
but the in the "Microsoft Extensible Firmware Initiative
FAT32 File System Specification" wrote this:
RootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec – 1)) / BPB_BytsPerSec;
could some one tell me why they plus the (BPB_RootEntCnt * 32) with (BPB_BytsPerSec – 1)?
i also see the 128 mmc card with winhex do the following formula on this Specification"
for count the FirstDataSector but as i guess the answer is wrong (it show one sector more than expect)
thanks. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Mar 28, 2005 7:27 am |
|
|
Quote: | RootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec – 1)) / BPB_BytsPerSec;
could some one tell me why they plus the (BPB_RootEntCnt * 32) with (BPB_BytsPerSec – 1)? | This seems like a methode to make sure the division is always ceiling the result. Without this addition the division command would give an integer result where the fraction part is thrown away. By adding (BPB_BytsPerSec – 1) the result will always be 1 higher, except for the special case where the fraction is exactly zero.
Quote: | i also see the 128 mmc card with winhex do the following formula on this Specification"
for count the FirstDataSector but as i guess the answer is wrong (it show one sector more than expect) | I think part of your post is missing here. What formula? |
|
|
nader
Joined: 29 Aug 2004 Posts: 12
|
|
Posted: Mon Mar 28, 2005 11:06 am |
|
|
hi,
thanks for your excellent answer.
as i understood when use the formula plus the (BPB_BytsPerSec – 1) so
we don't need any more to rounds up the RootDirSectors.is that right?
can i use all computation for fat in integer variable?(not float)
could you please tell me where can i find the some example code for fat16 for mmc card?
thanks alot. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Mar 28, 2005 11:58 am |
|
|
nader wrote: | hi,
thanks for your excellent answer.
as i understood when use the formula plus the (BPB_BytsPerSec – 1) so
we don't need any more to rounds up the RootDirSectors.is that right?
can i use all computation for fat in integer variable?(not float)
could you please tell me where can i find the some example code for fat16 for mmc card?
thanks alot. |
You certainly would not want to use float! Think about it, you wouldn't have factional numbers to access a sector, cluster, or byte would you.
Remember that ints for CCS are only 8 bits. You need to use a variable type that is large enough to hold the data.
Where can you find it? You might try searching!
http://www.ccsinfo.com/forum/viewtopic.php?t=22326&highlight=fat16 |
|
|
|