Rootdir in FAT12...

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.
f2

Re:Rootdir in FAT12...

Post by f2 »

Yes, and that's exactly what I call my variable, "LBA"! :D
Peter_Vigren

Re:Rootdir in FAT12...

Post 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???
f2

Re:Rootdir in FAT12...

Post 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...
Peter_Vigren

Re:Rootdir in FAT12...

Post 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.
f2

Re:Rootdir in FAT12...

Post by f2 »

Alright, lemme go retreive my code that does the necessary math and loading, etc...
Chris Giese

Re:Rootdir in FAT12...

Post 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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Rootdir in FAT12...

Post 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)
Peter_Vigren

Re:Rootdir in FAT12...

Post 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.
Chris Giese

Re:Rootdir in FAT12...

Post 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.
Peter_Vigren

Re:Rootdir in FAT12...

Post 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
Post Reply