A file named FISHES.DAT in the PROJECT: directory contains data about what the competitors at a fishing tournament caught on the first day of competition. You are to write a program that processes this data file and displays the following information about each angler: name, number of fish caught, weight of the heaviest fish s/he caught, length of the longest fish s/he caught. The display must show the anglers in alphabetical order and label each value output, preferably by displaying in columns.
Much of the work needed to do this task will be performed using three modules that are given to you. You need to write two assembly language components, including a main program that should work as follows.
1. Create an array of structs in your main program. There should be space for at least 200 anglers in the array. Each element in the array is a struct having the following form:
struct {
char name[22]; /* The angler's name */
int id; /* The angler's ID number */
short caught; /* Number of fish caught */
float heaviest; /* Heaviest fish caught */
short longest; /* Longest fish caught */
}
2. Make a loop to read in the data and place it into the array. A FORTRAN subroutine named READONE will be supplied that reads in all the data values for one angler from the file. READONE actually reads in a name, an ID, the number of fish caught and the weights and lengths of each of these fish. READONE then calls an assembly language procedure (named ONESBEST) to determine what the heaviest and longest fish are for this angler. Put the results returned by READONE (name, ID, number of fish caught, heaviest and longest) in one entry of the array.
3. After reading in all the data and putting it in array, call a C function named SORT, which will be supplied, to put the structs in alphabetical order based on the name component of each array element. The SORT function relies on another C function named COMPARE, also to be supplied, to rearrange the structs in the array.
4. Make a loop to display the contents of the array, in the order that SORT leaves them. The loop should display the name, ID, number of fish, heaviest fish weight, and longest fish length for each angler.
You have to write two assembly language components: the main program which performs the actions described previously and the procedure ONESBEST to determine the heaviest and longest fish caught by a person.
Here are the details of the interface to each of the modules. To call the READONE subroutine, six arguments are required.
FLAG a longword integer, must be set to zero for the first call only and checked after each call;
if zero when checked, eof has been reached; if 1 when checked, a record was read; if -1 when checked, an error occurred.
NAME a fixed-length string descriptor for a 22-character storage area that will hold an angler's name
ID
a longword integer that will hold an angler's ID
FISH
a word integer that will hold the number of fish caught by an angler
HEAVY
a float value that will hold the weight of the heaviest fish caught by an angler
LONG
a word integer that will hold the length of the longest fish caught by an angler
To call the SORT function, two arguments are required.
VAL an array of structs (VAL) of type angler which is expected to hold information for all anglers in the tournament
LEN a longword integer holding the number of records (structs) occupied in the VAL array
The READONE subroutine calls an assembly language procedure named ONESBEST that you must write. READONE expects to use five arguments when calling ONESBEST.
HVY an array of float values containing the weights of all fish caught by one angler
LNG an array of word values containing the lengths of all fish caught by one angler
FISH a word value containing the number of fish caught
HEAVY a float value computed by ONESBEST that represents the weight of the heaviest fish caught by the angler
LONG a word value computed by ONESBEST that represents the length of the longest fish caught by the angler
ONESBEST must return valid values to READONE even if the angler did not catch any fish at all.
The files that you will need are FISHES.DAT, SORT99.C, and READONE.FOR. They are in the PROJECT: directory. Copy them to your own directory. Then, compile SORT99.C and READONE.FOR. See the hints for directions on copying, compiling, and linking.
RULES: No supplied module may be changed in any way to write this program. The main program and the ONESBEST procedure must be in separate files.
Hand in a .LIS printout of both the main program and the ONESBEST procedure. Also, hand in an AUDIT.LOG file printout of the results of running the program.