saving a file in fat12

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator:Moderators

Post Reply
Master
Posts:5
Joined:Wed May 26, 2010 5:08 pm
Location:Babol
Contact:
saving a file in fat12

Post by Master » Sat Jul 10, 2010 7:14 pm

hello all , im trying to save a file in fat12 structure . the loading procedure is given in the tutorial but the saving procedure is not .
i myself came up with some sort of algorithm which im not sure of its correctness yet .
can you verify its integrity ?

you know , i dont know exactly how to go about it . !
i mean when we want to load a value from a cluster , we check to see if its even or odd ( the cluster i mean), if its even we shift the value 4 times to right and if its odd we and it with 0000111111111111b( meaning we want the low twelve bits) .
so do i have to consider this while saving too ? i mean should i do the same thing while saving or i should do it reversely ! i mean for even clusters instead of shr , i actually do shl, 4 times ( so that when loading when we shr 4 times , we get the actual value )
and for 'and'ing i dont know !
can anyone help me on this?
am i right so far?

can some one please give me the procedure of saving file in fat12 in Assembly ?
Thankyou in advance
Regards
Seyyed Hossein Hasan Pour Matikolaee
ustmb.ir

Hoozim
Posts:34
Joined:Sun Nov 21, 2010 6:40 pm

Re: saving a file in fat12

Post by Hoozim » Sun Nov 21, 2010 7:36 pm

I can't give you a procedure but a fairly simple way to do it would be to on saving:

1. Compute the size of the file (this should be easy)
2. Set all of the FAT entries that the file currently occupies and clean out the equivelent entries in the Data Region
3. Search through the FAT and reserve any free clusters
4. If there are enough, set them to point to each other and fill the Data Region

The directory that the file is located (the entry specifically) shoud be modified if the file's name has been changed. Hopefully you already have the routine to write 512 bytes to the media you are using (probably and FD).

Post Reply