Page 1 of 2
fat12 set cluster
Posted: Mon Aug 25, 2008 6:20 pm
by xyjamepa
Hi,
I'm trying to write a fat12 driver,but this time I'm writing it using assembly,
right now I don't know how to set an entry in the fat table to a specific value,
would you please give me a code snippt (asm code) about that...
Thanx.
Posted: Mon Aug 25, 2008 8:03 pm
by DT170x
I thought there is FAT, FAT16, and FAT32
FAT 12
It that odd
Re:
Posted: Mon Aug 25, 2008 8:17 pm
by suthers
DT170x wrote:I thought there is FAT, FAT16, and FAT32
FAT 12
It that odd
FAT12 definitely exist, trust me, I'm an OSdever
Jules
Re: fat12 set cluster
Posted: Mon Aug 25, 2008 8:20 pm
by DT170x
Sorry I didn't Know that.
Re: fat12 set cluster
Posted: Mon Aug 25, 2008 9:09 pm
by PatrickV
I think the number is the number of clusters per file it can handle for example FAT12- 12 Clusters? That i at least what i think it is. Please point out to me if I am wrong
Re: fat12 set cluster
Posted: Tue Aug 26, 2008 12:05 am
by egos
DT170x wrote:Sorry I didn't Know that.
Look at my
reset macro to generate sequential cluster chain for a file. Maybe this helps you.
Code: Select all
if id#_size>0
count=(id#_size+511)/512
cur=id#_base/512-(33-2)
repeat count
if %=count
val=0FFFh
else
val=cur+1
end if
if cur and 1
val=val shl 4
end if
disp=(cur*3)/2
load var word from 512+disp
var=var or val
store word var at 512+disp
store word var at 10*512+disp
cur=cur+1
end repeat
end if
Source:
mkfloppy.zip
Re: fat12 set cluster
Posted: Tue Aug 26, 2008 1:55 am
by ru2aqare
PatrickV wrote:I think the number is the number of clusters per file it can handle for example FAT12- 12 Clusters? That i at least what i think it is. Please point out to me if I am wrong
The number is the amount of
bits that are used to store each cluster number in the allocation table. So FAT12 theoretically supports 2^12 clusters (actually, it's around 4086, due to the last ten or so numbers being reserved), FAT16 theoretically supports 2^16 clusters (again, somewhat less), and FAT32 supports 2^28 clusters (although the name says 32, only 28 bits are used for the cluster number, the highest four bits are reserved; and again there are some reserved cluster numbers).
It would be a pretty serious limitation, if FAT12 could only handle files that are 12 clusters long. Even with the maximum cluster size 64KiB (if I remember correctly, FAT12 can't do clusters larger than this), that is only 768KiB - that would be pretty lame.
Re:
Posted: Tue Aug 26, 2008 2:05 am
by AJ
Hi,
DT170x wrote:I thought there is FAT, FAT16, and FAT32
As a word of warning, FAT (without a suffix) normally relates to FAT16 - at least on MS fdisk.
Cheers,
Adam
Re: fat12 set cluster
Posted: Tue Aug 26, 2008 3:32 am
by xyjamepa
Okay guys lets get back to the main point
some asm code snippt...
Re: fat12 set cluster
Posted: Tue Aug 26, 2008 4:22 am
by egos
abuashraf wrote:Okay guys lets get back to the main point
some asm code snippt...
It's so pitiful for me to give you my code
Re: fat12 set cluster
Posted: Tue Aug 26, 2008 9:48 am
by Dex
My OS has fat12, fat16, fat32 implemented (in fasm) you are free to use it, but you MUST include the licence, if you use any part of the code.
You can get it here:
http://dex4u.com/download.htm
Re: fat12 set cluster
Posted: Tue Aug 26, 2008 11:22 am
by salil_bhagurkar
Why don't you go for the actual math instead, and write a driver yourself using this
specification from MS... Reading it at the most 10 times, you should be able to understand the FAT in general (and hence FAT12).
Re: fat12 set cluster
Posted: Tue Aug 26, 2008 6:21 pm
by xyjamepa
I already wrote complete fat12 driver in C,but now I'm writing it in asm
but I'm really having problem with this specific function,I wrote "getFat" function by
myself ,but till now I couldn't get this function done.
anyway here's what I have...
Code: Select all
mov ax,word [cluster]
mov cx,ax
mov dx,ax
shr dx,0x0001
add cx,dx ;sum of (3/2)
mov bx,[es:0x500] ;location of fat table in memory
add bx,cx ;index into fat
test ax,0x0001
jnz .odd
.eve:
push bx
inc bx
and bx,0x0F
mov cx,[value]
and cx,0xF00
shr cx,0x0008
or bx,cx
mov cx,[value]
and cx,0x0FF
pop bx
mov [bx],cx
.odd:
and [bx],0x0F
mov cx,[value]
and cx,0x00F
shl cx,4
or [bx],cx
mov cx,value
and cx,0xFF0
shr cx,4
inc bx
mov bx,cx
Please note that I loaded the fat table into memory at [es:0x500]
Also "value" holds the value I want to set the entry to it
Re: fat12 set cluster
Posted: Wed Aug 27, 2008 10:30 pm
by Troy Martin
PatrickV wrote:I think the number is the number of clusters per file it can handle for example FAT12- 12 Clusters? That i at least what i think it is. Please point out to me if I am wrong
FAT12 uses a twelve-bit File Allocation Table, allowing 2^12-19 clusters. At 8KB per cluster (16 sectors) that makes a volume max size of 32 MB.
Re: fat12 set cluster
Posted: Thu Aug 28, 2008 6:21 am
by xyjamepa
here's what I got till now...
Code: Select all
setcluster:
mov ax,word [cluster] ;current cluster
mov cx,ax
mov dx,ax
shr dx,0x0001
add cx,dx ;sum of (3/2)
mov bx,[es:0x500] ;location of fat table in memory
add bx,cx ;index into fat
mov dx, WORD [bx] ;read two bytes from FAT
test ax,0x0001
jnz .odd
.eve:
and [value],0xFFF
and bx,0xF000
jmp done
.odd:
shl [value],4
and bx,0x000F
done:
or bx,[value]
ret
would any one please check this function and till me what bugs does it have?
Thanx.