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_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
Code: Select all
First Custer = FirstDataSector + DIR_FstClusLO;
// Fist cluster = 36;
What am I doing wrong.
How do I get the sector/clustor were the file is.
Code: Select all