Page 2 of 2
Re:Rootdir in FAT12...
Posted: Fri Jun 28, 2002 7:55 am
by f2
Yes, and that's exactly what I call my variable, "LBA"!
Re:Rootdir in FAT12...
Posted: Fri Jun 28, 2002 6:29 pm
by Peter_Vigren
Chris Giese wrote:
>Mov Ah,2
>Mov Al,1
>Mov Cl,2???; Second sector
>Mov Ch,1???; Second cylinder
>Mov Dh,0
>Mov Dl,0
>Mov Bx,DiskBuffer
>Int 13h
Try this:
Mov Ah,2
Mov Al,1
Mov Cl,2???; Second sector
Mov Ch,0???; Second cylinder (no! not yet)
Mov Dh,1 ; head 1
Mov Dl,0
Mov Bx,DiskBuffer
Int 13h
I really don't understand this... Why the first cylinder and the second head???
Re:Rootdir in FAT12...
Posted: Fri Jun 28, 2002 7:40 pm
by f2
I'm telling you, it's a bad idea to hard code the tracks and sectors, etc. The point of implementing the FAT FS is for CONVENIENCE! Work out where the root dir is (especially for most FAT FSes, not just 12) with arithmatic. It will save you a lot of trouble in the future...
Re:Rootdir in FAT12...
Posted: Fri Jun 28, 2002 8:09 pm
by Peter_Vigren
Tommy wrote:
I'm telling you, it's a bad idea to hard code the tracks and sectors, etc. The point of implementing the FAT FS is for CONVENIENCE! Work out where the root dir is (especially for most FAT FSes, not just 12) with arithmatic. It will save you a lot of trouble in the future...
Of course I wont hardwire the numbers! The code will use whatever data which is in the bootsectors and stuff but I need to have a way to control the code, don't I? And I _can't_ calculate where anything is unless I know _where_ the things should be placed and why.
Re:Rootdir in FAT12...
Posted: Fri Jun 28, 2002 9:05 pm
by f2
Alright, lemme go retreive my code that does the necessary math and loading, etc...
Re:Rootdir in FAT12...
Posted: Fri Jun 28, 2002 9:18 pm
by Chris Giese
Peter_Vigren wrote:
I really don't understand this... Why the first cylinder and the second head???
As the LBA value increases, first the sector value increases, then the head, then the cylinder (or track) value.
sector = lba % sectors + 1;
head = (lba / sectors) % heads;
track = (lba / sectors) / heads;
On a typical 1.44 meg floppy,
sectors = 18
heads = 2
root directory starts at lba = 19
The equations above give
sector = 2
head = 1
track = 0
For INT 13h:
CH = cylinder (or track) = 0
CL = sector = 2
DH = head = 1
Re:Rootdir in FAT12...
Posted: Sat Jun 29, 2002 10:37 am
by Pype.Clicker
hmm ... don't forget that the number of FAT copies isn't fixed and should be read out of the BOOT sector (unless you format all your floppies with a program of yours
, as well of the amount of reserved sectors (bootstrap extension, including the bootsector itself), so the root directory is located at
BOOT.nb_reserved_sectors + (BOOT.nb_FATs)*BOOT.fat_size
now, if i look at a typical floppy, i see
BOOT.reserved = 1 (offset 0E in /dev/fd0)
BOOT.nb_FATs = 2 (offset 10 in /def/fd0)
BOOT.FAT_size = 9 (offset 16 in /dev/fd0)
FAT#1 starting at 200 in /dev/fd0 (sector #02h)
FAT#2 starting at 1400 in /dev/fd0 (sector #0Bh)
ROOT DIR starting at 2600 in /dev/fd0 (sector #14h)
Re:Rootdir in FAT12...
Posted: Sat Jun 29, 2002 2:30 pm
by Peter_Vigren
To Chris Giese: If I have understood you correctly, the "incrementation order" goes like sectors, heads and tracks (when sectors is "overloaded" heads is increased and so on)? I always thought it was like sectors, cylinders (tracks) and heads...
By the way... Do % mean "mod"?
To Pype.Clicker: As I wrote above, the code will of course check the boot sector in question for the correct values.
Re:Rootdir in FAT12...
Posted: Sat Jun 29, 2002 8:33 pm
by Chris Giese
>To Chris Giese: If I have understood you correctly, the
>"incrementation order" goes like sectors, heads and tracks
>(when sectors is "overloaded" heads is increased and so
>on)?
Correct
>By the way... Do % mean "mod"?
Yes, sorry. Remainder after division. I was going to note that, but the text disappeared for some reason.
Re:Rootdir in FAT12...
Posted: Sat Jun 29, 2002 8:39 pm
by Peter_Vigren
Big thanks (yikes! I have seen and written "thanx" too much so it was hard spelling it right
) for bringing that to my attention... without it I would have killed myself probably and on my grave it would say something like "Here lies a boy which couldn't find the right sector no matter how he tried...".
Once again: BIG THANKS! ;D