One more(last) question about DOS FAT. 
Author Message
 One more(last) question about DOS FAT.

The is the last lame question about how DOS FAT works... I've looked at
some docs and I was wondering if FAT-12 is made up of an array of
12-bits or words? what I'm trying to say is... do I make an array of
words, read a word and cut the high nibble of the high byte off? or do I
have to "extract" 12-bits? I thought is was made up of 12-bits but I
read a sentence in a doc that said 12-bit fats don't use the high nibble
of the high byte... that led me to belive that it is made up as words...
I'm very confused :(



Sun, 11 Apr 1999 03:00:00 GMT  
 One more(last) question about DOS FAT.

Quote:

> some docs and I was wondering if FAT-12 is made up of an array of
> 12-bits or words? what I'm trying to say is... do I make an array of

To extract FAT-12 entry of index I need:
- get word of offset 3*I/2
- if I is odd shift right the word 4 bits
- get low 12 bits of the value

If FAT entries contain 111h,222h,333h,etc. the FAT is:
media_byte,FF,FF,11,21,22,33,43,44 (note index 0 and 1 aren't used).
In reverse order it looks better: 44,43,33,22,21,11,FF,FF,media_byte.
Typically on a floppy start of FAT is FD,FF,FF,03,40,00,05,60,00,...



Mon, 12 Apr 1999 03:00:00 GMT  
 One more(last) question about DOS FAT.


Quote:
> I've looked at some docs and I was wondering if FAT-12 is made up of
> an array of 12-bits or words?

[ ... ]

The values are 12 bits each, with 2 entries packed into 3 bytes.

--
    Later,
    Jerry.



Wed, 14 Apr 1999 03:00:00 GMT  
 One more(last) question about DOS FAT.

: The is the last lame question about how DOS FAT works... I've looked at
: some docs and I was wondering if FAT-12 is made up of an array of
: 12-bits or words? what I'm trying to say is... do I make an array of
: words, read a word and cut the high nibble of the high byte off? or do I
: have to "extract" 12-bits? I thought is was made up of 12-bits but I
: read a sentence in a doc that said 12-bit fats don't use the high nibble
: of the high byte... that led me to belive that it is made up as words...
: I'm very confused :(

If they had only used 12 bits of a 16-bit word and discarded the rest
there would have been no need to have a new 16-bit FAT structure.  The
12-bit FAT system crams two FAT entries into three bytes.

I find that the best way to view it is by printing the bytes in reverse.

The bytes:

        12 34 56 78 9A BC DE F0 12  

in reverse:

        12 F0 DE BC 9A 78 56 34 12

Regroup as nibbles in sets of 3:

        12F 0DE BC9 A78 563 412

or to view the original bytes in order a different way:

        12 34 56 78 9A BC DE F0 12  -- points to cluster 412
        ==  =

        12 34 56 78 9A BC DE F0 12  -- cluster 563
           =  ==

        12 34 56 78 9A BC DE F0 12  -- cluster A78
                 ==  =

        12 34 56 78 9A BC DE F0 12  -- cluster BC9
                    =  ==

        12 34 56 78 9A BC DE F0 12  -- 0DE
                          ==  =

        12 34 56 78 9A BC DE F0 12  -- 12F
                             =  ==

Given a cluster number, [ pseudo-code -- no specific language ]

        temp   = cluster * 3;
        offset = temp / 2;  // integer division -- address of entry in FAT
                            // relative to the start of the FAT.

        FAT_entry = (byte) FAT[offset] + 256 * (byte) FAT[offset+1];
or
        FAT_entry = (word) FAT[offset] ;  // although offset may be odd

        if temp AND 1 then
                FAT_entry = (FAT_entry AND 0FFF0h) SHR 4 ;  // odd entry
        else
                FAT_entry = (FAT_entry AND 00FFFh) ; // even entry
        endif ;

                Norman De Forest

                http://www.chebucto.ns.ca/~af380/Profile.html

.........................................................................
Q.  Which is the greater problem in the world today, ignorance or apathy?
A.  I don't know and I couldn't care less.
.........................................................................
For those robots that gather e-mail addresses from postings and sig. blocks:
Junk e-mail received so far this month from:


--



Wed, 14 Apr 1999 03:00:00 GMT  
 One more(last) question about DOS FAT.

: The is the last lame question about how DOS FAT works... I've looked at
: some docs and I was wondering if FAT-12 is made up of an array of
: 12-bits or words?
It's an array of 12 bits.

Each three bytes contain two Fat entries, but I've never bothered
to work out the exact format of these three bytes. One way to see
it is to copy a large file onto a blank floppy disk and then look
at the FAT using DEBUG. That way the file should be contiguous,
and you can work out how each FAT entry points to the next FAT
entry.

The debug commands would be something like.
L 100 1 1 1
D 100 200

That would hopefully read the start of the FAT into memory and
display the start of it. Though you will have to check the syntax
as I wrote that bit from memory.

: what I'm trying to say is... do I make an array of
: words, read a word and cut the high nibble of the high byte off? or do I
: have to "extract" 12-bits? I thought is was made up of 12-bits but I
: read a sentence in a doc that said 12-bit fats don't use the high nibble
: of the high byte... that led me to belive that it is made up as words...
: I'm very confused :(

Youv'e got me confused now. You lost me at around about the 3rd line.

Richard.



Sat, 24 Apr 1999 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. One more(last) question about DOS FAT.

2. One more(last) question about DOS FAT.

3. One more(last) question about DOS FAT.

4. one LAST PNG question - very very urgent

5. DOS FAT file routines

6. DOS FAT

7. DOS FAT

8. Accessing FAT in ms-dos

9. Accessing FAT in ms-dos

10. How Fat is Fat?

11. New FAT old FAT

12. cancel that last one!

 

 
Powered by phpBB® Forum Software