Page 1 of 2

Rootdir in FAT12...

Posted: Tue Jun 25, 2002 11:29 am
by Peter_Vigren
What should I set the registers to if I want to read the first sector of the root directory on a FAT12 floppy by using Int 13h? I have tried and tried to let one of my programs find a specific file on one of my floppies. Since I stored it with Windows when the floppy was clean, it should be on the first rootsector. However, I try and try but the program won't find it... I have tested the program with a simulation of a rootsector and it works then...

So the question is, as I wrote above, what should I set the registers to when reading the first rootsector using Int 13h??

Re:Rootdir in FAT12...

Posted: Tue Jun 25, 2002 11:36 am
by Jonathan
Are you sure It is on the first sector? Else you can use partcopy or somelese program that writes files to the first sectors on a floppy!

Hmmmm.....ser att du ?r fr?n Sverige? R?tta mig om jag har fel? =)

Re:Rootdir in FAT12...

Posted: Tue Jun 25, 2002 11:41 am
by Peter_Vigren
It should be on the first sector in the root since that is the first file created on the floppy. Yeah but I want to support FAT12 (FAT at all...)...

Jupp, jag ?r fr?n Sverige jag. :-)

Re:Rootdir in FAT12...

Posted: Tue Jun 25, 2002 12:20 pm
by f2
To get the sector of the root dir, you simply have to add up the sectors before the root dir. FAT sectors, hidden sectors, reserved sectors, etc...

Re:Rootdir in FAT12...

Posted: Tue Jun 25, 2002 12:33 pm
by Peter_Vigren
I did that... 1 bootsector and 2 FAT's ? la 9 sectors each = 19 sectors...

According to that, the int 13h should look like:

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

But it doesn't work... I can't find the entry there...

Re:Rootdir in FAT12...

Posted: Tue Jun 25, 2002 12:36 pm
by f2
I don't know why you're using "hard" numbers. That little "function" would only be for the root dir then. What you would be better off doing is doing the necessary steps to getting the root dir and then do some math in the function to read the sector (to get the logical sector) of the root dir. If you are really struggling, I could post the code that does the "math" and my ReadSector function.

Re:Rootdir in FAT12...

Posted: Tue Jun 25, 2002 12:41 pm
by f2
Oh, and also make sure you're checking each entry for the CORRECT file name and incrementing by 32 in the sector if you don't find the filename you're looking for in that entry. There is quite a lot of room for errors when reading the root dir.

Like I said, if you want I'll post my tid-bit of code that does this.

Re:Rootdir in FAT12...

Posted: Tue Jun 25, 2002 12:43 pm
by Peter_Vigren
Of course the code is for the root dir only. That's the whole meaning with having a code searching the root dir...

What I asked for is if someone know what to fill the registers with when I want to use int 13h to get the first rootsector on a 1.44 Mb FAT12 floppy (because of my reasoning above)...

When you mean sector, do you refer to cluster? Since you mention both sector and logical sector...

Re:Rootdir in FAT12...

Posted: Tue Jun 25, 2002 12:46 pm
by Peter_Vigren
As I wrote in the starting of the post, is that the code searching for the filename works (it uses 32 bytes entries and search the whole buffer) when simulating a directory sector. But not on disk...

"Like I said, if you want I'll post my tid-bit of code that does this."

Looking how others do it doesn't hurt so be my guest :-)

Re:Rootdir in FAT12...

Posted: Tue Jun 25, 2002 3:26 pm
by f2
Peter_Vigren wrote: Of course the code is for the root dir only. That's the whole meaning with having a code searching the root dir...

What I asked for is if someone know what to fill the registers with when I want to use int 13h to get the first rootsector on a 1.44 Mb FAT12 floppy (because of my reasoning above)...

When you mean sector, do you refer to cluster? Since you mention both sector and logical sector...
A cluster is a number of sectors (in case of FAT12, one sector per cluster). I'll go retreive the code and post it as soon as possible. Hopefully tonight...

Re:Rootdir in FAT12...

Posted: Tue Jun 25, 2002 5:41 pm
by Peter_Vigren
I know what a cluster is but I wanted to know if you refered to one when you talked about sectors and _logical_ sectors:

"What you would be better off doing is doing the necessary steps to getting the root dir and then do some math in the function to read the sector (to get the logical sector) of the root dir."

Re:Rootdir in FAT12...

Posted: Tue Jun 25, 2002 9:39 pm
by Chris Giese
>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 think what he means by "logical sector"...

Posted: Thu Jun 27, 2002 3:42 am
by Kenneth Garin
logical sectors are linear, or a flat number ranging from 0 (zero) to the max number the variable or regester may hold. A non logical sector, aka: the "S" in CHS can only range in the amount of sectors the drive has per track, not in total (unlike the linear above).
I hope this makes sence since computer terms ALWAYS gets messy :) (unless you've been doing this stuff for years).
Im not sure if this is even what you were questioning.
Kg.

Re:Rootdir in FAT12...

Posted: Thu Jun 27, 2002 12:38 pm
by f2
Logical sector is, yes, one number. THE number of the sector on the disk. But, with the read sector function, you have to convert this number, because that's not how the BIOS interrupt reads consecutive sectors.

Re:Rootdir in FAT12...

Posted: Thu Jun 27, 2002 3:49 pm
by Peter_Vigren
Oh you mean LBA...