IUP Computer Science
CO 300 Spring 2000

Project #5
(Due 5 pm 14 April 2000)

A file named WATCHERS.DAT in the PROJECT: directory contains data about what the participants in an annual bird count saw. You are to write a program that processes this data file and displays the following information about each bird watcher: name, highest number of birds in a category, name of that category, lowest number of birds in a category, name of that category. The display must show the bird watchers 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 100 bird watchers in the array. Each element in the array is a struct having the following form:
         struct {  char    name[24];     /* The watcher's name */
                   int     most;         /* Highest number in any category*/
                   short   highcat;      /* Number of the high category */
                   float   least;        /* Lowest number in any category */
                   short   lowcat;       /* Number of the low category */
         }
    
  2. Make a loop to read in the data and place it into the array. A FORTRAN subroutine named GETONE will be supplied that reads in all the data values for one watcher from the file. GETONE actually reads in a name and the number of birds seen in each of the five categories. GETONE then calls an assembly language procedure (named EXTREMES) to determine what the highest number and its category and lowest number and its category for this bird watcher. Put the results returned by GETONE (name, most, highcat, least, and lowcat) in one entry of the array. Incidentally, the category numbers that are returned are in the range 0 to 4; there are five categories.
  3. After reading in all the data and putting it in the array, call a C function named ALPHASORT, which will be supplied, to put the structs in alphabetical order based on the name component of each array element. The ALPHASORT 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 ALPHASORT leaves them. The loop should display the name, highest number seen in any category, that category's name, lowest number seen in any category, and that category's name for each watcher. The bird category names are Swimming Birds, Sea Birds, Birds of Prey, Song Birds, and Miscellaneous (in that order).

You have to write two assembly language components: the main program which performs the actions described previously and the procedure EXTREMES to find the highest count and category and lowest count and category.

Here are the details of the interface to each of the modules. To call the GETONE 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 24-character storage area that will hold an angler's name

MOST
a longword integer that will hold the number of birds from the highest category

MCAT
a word integer that will hold the category number for the highest birds

LEAST
a longword value that will hold the number of birds from the lowest category

LCAT
a word integer that will hold the category number for the lowest birds

To call the ALPHASORT function, two arguments are required.

VAL
an array of structs (VAL) of type watcher which is expected to hold information for all bird watchers in the bird count

LEN
a longword integer holding the number of records (structs) occupied in the VAL array

The GETONE subroutine calls an assembly language procedure named EXTREMES that you must write. GETONE expects to use five arguments when calling EXTREMES.

BIRDS
an array of five longword values containing the number of birds seen by one watcher in each of the five categories

MOST same as for GETONE - this is a result produced by EXTREMES

MCAT same as for GETONE - this is a result produced by EXTREMES

LEAST same as for GETONE - this is a result produced by EXTREMES

LCAT same as for GETONE - this is a result produced by EXTREMES

EXTREMES must return valid values to GETONE even if the watcher did not see any birds and even if there are several categories tied for the highest or lowest.

The files that you will need are WATCHERS.DAT, ALPHASORT.C, and GETONE.FOR. They are in the PROJECT: directory. Copy the last two files to your own directory. Then, compile ALPHASORT.C and GETONE.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 EXTREMES procedure must be in separate files.

Hand in a .LIS printout of both the main program and the EXTREMES procedure. Also, hand in an AUDIT.LOG file printout of the results of running the program.