FAT12 Problems

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
B.E

FAT12 Problems

Post by B.E »

I'm have trouble this finding the actual data that the file contains on the floppy disk. I can find the Entry in the FAT but I not quite sure what do after that.

This is how i understand it (I got this information from Microsoft).

this is my bootsector

Code: Select all

start:
   jmp short begin               ; Jump to start of bootstrap code

nop
BS_OEMName          db "MSWIN4.1"   ; Name of the volume
BPB_BytsPerSec      dw 512         ; Number of bytes per sector
BPB_SecsPerClus     db 1         ; Number of sectors per cluster
BPB_RsvdSecCnt      dw 1         ; Number of sectors reserved
BPB_NumFATs         db 2         ; Number of FATs
BPB_RootEntCnt      dw 0E0h         ; Number of entries in the root directory
BPB_TotSec16      dw 2880         ; Size of volume = BPB_TotSec16 * (BPB_BytsPerSec)
BPB_Media         db 0f8h         ; Media type (e.g removable)
BPB_FATSz16         dw 9         ; Sectors occupied by one FAT
BPB_SecPerTrk      dw 18         ; Number of sectors per track (used by Int 13h)
BPB_NumHeads      dw 2         ; Number of heads (Used by Int 13h)
BPB_HiddSec         dd 0         ; Number of hidden sectors
BPB_TotSec32      dd 0         ; Number of sectors ((if BPB_TotSec16 != 0 then this field must be zero)
                           ; else this field must be zero
BPB_DrvNum         db 0         ; Drive Number (Used by int 13h)
BS_Reserved1      db 0         ; Reserved for Windows NT (This field must be 0)
BS_BootSig         db 29h         ; Extended boot signature 
BS_VolLab         db "NO NAME    "; Volume Label ("NO NAME    " has no name)
BS_FilSysType       db "FAT 12  "   ; Name of the file system used 
                           ; this field is not used to determin the file system type
DIR_FstClus : the first clustor number
DIR_FstClusLO = 2;
To calculate the number of root directory sector:

Code: Select all

RootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec ? 1)) / BPB_BytsPerSec;
// RootDirSectors = 15


To calculate the first data sector:

Code: Select all


FirstDataSector = BPB_ResvdSecCnt + (BPB_NumFATs * BPB_FATSz16) + RootDirSectors;
// FirstDataSector = 34

so to work out where the data is on the disk:

Code: Select all

First Custer = FirstDataSector + DIR_FstClusLO;
// Fist cluster = 36;
but when I search my floppy disk for the data I'd put in the file, the data is in sector number 33.

What am I doing wrong.

How do I get the sector/clustor were the file is.
B.E

Re:FAT12 Problems

Post by B.E »

I figured out what the problem was. I had to subtract two from DIR_FstClusLO which makes First Custer 34 and sector 0 is counted and the first sector
Post Reply