Finally, The FAT16 library for my CZ-80 Computer is now ready. I`ve implemented only basic, most useful features, which the system will most benefit from. The ROM Monitor has been upgraded to version 2.0 now.
Features of my FAT16 implementation:
- Directory listing
- File reading
- File writing
- File creating
- File deleting
Limitations:
- Only root directory, no support for subdirectories.
- Filenames in 8.3 format – no support for long filenames.
- Only first partition on the disk is used, others are ignored.
- File attributes and timestamps are ignored.
FAT16 implementation was very time consuming project. The ROM Monitor code is nearly twice bigger after including the FAT16 library. However, it seems everything is working properly. Some new commands have been added to the ROM Monitor command list:
- dir – directory listing with automatic paging.
- type – displays a textfile on the screen, automatic paging included.
- fload – loads a file into memory at specified address
- rsave – saves a range of memory into a file
- bsave – saves specified number of bytes from starting address in memory into a given file
- del – deletes a file
Detailed descriptions are included in PDF manual in download section. We will now check some examples and illustrate them with screenshots from the system:
First, let`s gather some example files, and place them on a CF card:
Now, let`s insert the CF card into CZ-80 Computer, and power it on. After issuing the dir command, we can see the contents of the root directory:
We can see file names with extensions, and filesizes in hex. Now, lets examine the memory from address d000:
There is only garbage here. Let`s load the contents of “autoexec.bat” to that location. The command is written on the screen. After executing it, we`ll check the memory contents again:
Yes! The autoexec.bat file was loaded at d000h address in memory! Now, lets change first 3 letters “SET” into “ABC”, and save the modified data into a new file called “autoexec.bak”. The steps are shown below:
Now, let`s see (with a dir command) if the file was really created:
Yes, it was! It also has the same filesize as the original file. We`ll now check the contents of “autoexec.bak” with type command, the effect is shown below:
As expected – the modified memory contents were succesfully saved into newly created file. We will now delete the original file, and see if it is really gone by printing out the directory contents again. All is shown on the screen above.
I`ve also included a small help.txt file in which I`ll keep short command descriptions for convinient use. It can be viewed at any time by issuing “type help.txt” on the ROM Monitor screen:
There are lots of resources and documentations on FAT16 available on the internet and in many books. I was using only 2 documents:
“Fat16 Interface for MSP430” Application Note by Allan Evans. It is a very nice, clear and simple introduction to FAT16, focused on the use of FAT16 with a small microcontroller. Allan`s note is a good reader, it gave me the feeling “OK, I can do this !” . I highly recommend it for starters:
http://www.digitalspirit.org/file/index.php/obj-download/docs/fat/appnote_fat16.pdf
Second document is a FAT16 File System Spectfication. I found this on the “Maverick OS” project site here:
http://www.maverick-os.dk/FileSystemFormats/FAT16_FileSystem.html
This document is very comprehensive, it contains absolutly everything needed for full FAT16 implementation. The most important part however, is the “Calculation Algorithms” section. All needed formulas are gathered there in one place. Just take and use them!
During my development of the FAT16 library, I was extensively using “WinHex” by X-WAys Software Technology AG. Great tool for debugging and learning – easy to use, very intuitive. I would`nt manage to finish the project without this fantastic tool. Highly recommended.
Uwe G. said:
Hi,
Is it necessary to save the FAT in a RAM area (somethink like a FAT Buffer) ?
LikeLike
ciernioo said:
Hi, No – there is no need for any RAM buffer (except for obvious 512 byte sector data buffer for any atomic read-write operations). My whole FAT16 implementation relies on a few 4-byte counters/variables maintained in RAM and a set of functions for modifying their value (addition,substraction,simple multiplication and division).
LikeLike