Starting from:

$30

Homework #03 File Systems Solution

In this homework, we will use our 8080 Emulator with a more advanced OS that supports a simple file system.




Our new OS will offer the following system calls in addition to the calls of HW2. Note that you should update your ASM files to include the definitions of the new system calls. Your new OS calls are







Call
Params to pass
Function
FileCreate
Register A =12
It works like the file create call of UNIX systems.


The file name
On fail, returns 0 in register B. On success, it


is at address
returns 1. There are no owners, no access


BC.
permissions.








Register A = 13,
It works like the close call of UNIX systems. It
FileClose
Register B
closes the file. On fail, returns 0 in register B. On


holds the file
success, it returns 1.


handle ID








FileOpen
Register A = 14
It works like the file open call of UNIX systems. It


The file name
returns the file handle ID in register B on success.


is at address
On fail, returns 0. The file is always opened for


BC.
read/write mode. There are no owners, the file




pointer points to the beginning of the file.
FileRead
Register A = 15,
It works like the read call of UNIX systems. It


Register BC
reads the file. On fail, returns 0 in register B. On


holds the adress
success, it returns the number of bytes read. It ad-


of the buffer.
vances the file pointer by the number of bytes read.


Register D




holds the




number of bytes




to read, Register




E holds the file




handle.








FileWrite
Register A = 16,
It writes to the file. On fail, returns 0 in register B.


Register BC
On success, it returns the number of bytes written.


holds the adress
It advances the file pointer by the number of bytes


of the buffer.
written. It append the file if needed.


Register D




holds the




number of bytes




to write,




Register E




holds the file




handle.








FileSeek
Register A = 17,
It moves the file pointer to the desired seek posi-


Register BC
tion. On fail, returns 0 in register B. On success, it


holds the seek
returns 1.


value. Register




D holds the file




handle.








DirRead
Register A = 18,
We have a single directory in our system: Root.


Register BC
The information about the files will be read and


holds the adress
will be put to the memory as a null terminated


of the buffer to
string.


write the




directory




information.








You will use contiguous layout model for keeping your files on the disk. You should be careful about appending files and not overwriting the other files. Your block size is 256 bytes and your total disk space is 1 MB. The maximum file size is limited by the addressable seek values. You will use a single C file to keep all the file system.




You need to keep an open file table which should keep necessary information about your files. Your file handles are pointers to this table.




Your file attributes should include




File name



File creation, last modification and last access time



File size in bytes.



You will write 4 ASM programs for your new system.




P1: A program that creates a file (file name is given from the keyboard) writes single byte integers from 0 to 50 to this file and closes it.



P2: A program that opens a file (name is given from the keyboard) and reads all the numbers from the file and prints them to the screen.



P3: A program that read the root directory and prints all the information to the screen.



P4: A program that opens a file, appends 10 numbers to the end of the file. These numbers should be the continuation of the existing numbers.
You will provide the main simulation program as follows




Write a simulation program that runs your systems with some command line parameters. There should be parameters for the program name and debug flag.

sim8080 exe.com filesystem.dat 1 : will read the program from exe.com



and the filesystem.dat as the file system. In debug mode 1, the contents of the file table will be printed to the screen after each system call. At the end of the simulation, the directory information will be printed.




In Debug mode 0, the program will be run. At the end of the simulation, the directory information will be printed.



We will provide the submission instructions in a separate document. You should strictly follow these instructions otherwise your submission may not get graded. You will submit the following files for this homework




main.cpp



gtuos.cpp and gtuos.h



4 ASM programs.



At least 5 filesystem files on which that we can run your ASM files.

More products