FAT12 Question

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
renovatio
Member
Member
Posts: 57
Joined: Fri May 23, 2008 5:13 am

FAT12 Question

Post by renovatio »

Where can I get an official FAT12 file system specification?

Thanks in advance.
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Post by suthers »

http://www.osdever.net/documents/fatgen ... ?the_id=40
You should have looked for them yourself first their really not that hard to find.
Jules
renovatio
Member
Member
Posts: 57
Joined: Fri May 23, 2008 5:13 am

answer

Post by renovatio »

isn't that reference about FAT32???? i need about fat12... but thanks anyway!!!!!!!!!!
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Post by suthers »

I't gives the standard fat system workings (applicable to all fats) and then it gives the workings of fat 32, while giving its differences from fat12/16, so it is in fact the doc for the 3 in 1
Jules

edit: Yah I did read the title...
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: answer

Post by Brynet-Inc »

renovatio wrote:isn't that reference about FAT32???? i need about fat12... but thanks anyway!!!!!!!!!!
That was kinda rude, I believe he was only trying to help you.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: answer

Post by suthers »

Brynet-Inc wrote:
renovatio wrote:isn't that reference about FAT32???? i need about fat12... but thanks anyway!!!!!!!!!!
That was kinda rude, I believe he was only trying to help you.
and I gave you what was necessary, you just needed to read on a bit...

Jules
renovatio
Member
Member
Posts: 57
Joined: Fri May 23, 2008 5:13 am

answer and question

Post by renovatio »

Answer:

i'm sorry if i sounded rude... sincerely i am argentinian and am not the best speaking english... that's why maybe i didn't expressed well.... anyway, i'm really pleased for that information....

Question:

I wrote a program in asm to read a FAT:

Code: Select all

org 100h

mov ah, 2h
mov al, 14
mov bx, fat
mov ch, 1
mov cl, 1
mov dh, 0
mov dl, 0
int 13h

mov si, fat

print_again:
      mov al, [si]
      mov ah, 0eh
      int 10h
      mov ah, 0h
      int 16h
      inc si
      jmp print_again

fat:
      times 7168 db 0
AL = Numbers of sectors to read: Dividing the number of root entrys by bytes per sector will tell us how many sectors the root entry uses.

FATSize = (Num Fats * Sector Per FAT (9) + Reserved Sector + BootSector) = 19

CH & CL = FATSize to CHS

But I can't read any file name.... Is there any problem in my code???

Thanks for reading...
svdmeer
Member
Member
Posts: 87
Joined: Tue May 06, 2008 9:32 am
Location: The Netherlands

Post by svdmeer »

Under which OS are you running this program?
You begin with org 100h so it's looks like a .COM-program running under DOS. Do you run it under a stand-alone DOS or DOSbox from Windows?

About function 2 int 13h:
AH = 02h
AL = number of sectors to read (must be nonzero)
CH = low eight bits of cylinder number
CL = sector number 1-63 (bits 0-5)
high two bits of cylinder (bits 6-7, hard disk only)
DH = head number
DL = drive number (bit 7 set for hard disk)
ES:BX -> data buffer
Return:CF set on error
if AH = 11h (corrected ECC error), AL = burst length
CF clear if successful
AH = status (see #00234)
AL = number of sectors transferred (only valid if CF set for some
BIOSes)
You are reading cylinder 1, sector 1, head 0 of disk #0, so you are reading from a floppy.

- Are you use you are reading the right sectors of the rootdir?
You are reading cyliner 1 sector 1. It depends on the geometry of your floppy (720k, 1440k, etc..) which absolute sector number is addressed with cylinder 1 sector 1. I don't think your rootdir begins at cylinder 1 sector 1 it's just a guess.
You need to read the bootsector (first sector of a floppy, cyl=0, head=0, sect=1) and calculate the absolute sector number of your rootdir. You need to convert that number to the parameters in CH, CL and CH.

- Are you sure no errors occured? You don't check for it (cf=1). When there is an error, you have to retry sometimes because some errors occur then the motor of your floppydrive didn't fully spin up.
FATSize = (Num Fats * Sector Per FAT (9) + Reserved Sector + BootSector) = 19

CH & CL = FATSize to CHS
I assume you use an ordinary 1.44 mb floppy.
Geometry 18 sectors, 2 heads and 80 cylinders (18x2x80=2880; 2880x512/1024=1.44mb).

9 sectors per FAT is a normal value with 1.44mb floppy's.
So you can expect the first sector of the rootdirectory to be 1 + 9 x 2 = 19. But don't assume. It's ok to use 19 for testing purposes, but some floppy's can have reserved sectors.

So you need to read from absolute sector 19 (count from zero).
There are 18 x 2 = 36 sectors per cylinder. Sector 19 is at cylinder 0.
There are 18 sectors per head. So you want to read from head number 1 and sector number 1. Function 2 int 13h counts sector number from 1, so you need sector 2 (1+1).

Read from head 1 and sector 2:

Code: Select all

mov ch,0 ; low eight bits of cylinder number
mov cl,2; CL = sector number 1-63 (bits 0-5) high two bits of cylinder (bits 6-7, hard disk only)
mov dh,1 ; DH = head number
You are reading with parameters ch=1, cl=1, dh=0, so cylinder 1, sector 0 (1-1=0, because int 13h function 2 counts sectornumbers from 1), head 0. Cylinder 1 means addressing absolute sector number 1 x 2 x 18 + 0 = 36 on a 1.44mb floppy. That's far beyond the rootdir, at the area with files and other directories, so you get garbage.

Tip: Search for some information about how geometry of disks work.
Last edited by svdmeer on Sun Jun 08, 2008 10:53 am, edited 2 times in total.
renovatio
Member
Member
Posts: 57
Joined: Fri May 23, 2008 5:13 am

answer

Post by renovatio »

I'm sorry but i made a mess... i will correct somethings i noticed when reading your reply.... lots of thanks.....
Post Reply