IUP Computer Science
CO 300 Spring 1998

Project #5
(Due 17 April 1998)

The file PROJECT:5DATA.DAT contains records that are each 35 bytes long. Each record consists of a 24-character encrypted name, an ID number (a longword), a 5-character date, and a tally (a word). The tally values range from 1 to 500. The date is in the form mm/dd where dd is a day number and mm is a month number (leading zeros are used). The file may contain as many as 1000 records of this form.

You will be given a Pascal procedure called LOAD that is designed to read the records of the file into an array of records in memory. The LOAD procedure takes two arguments: the address of the array, and the address of a longword that is to hold the number of records. When LOAD is called, it fills the array, counts the records, and puts the count in the longword that is to hold the number of records.

You will also be given a C function called SORT that is designed to sort the records in the array on the basis of the date field of each record. The SORT function takes two arguments: the address of the array and the address of the number of records. When SORT is called, it reorders the records in the array, leaving them sorted in ascending order based on the date values.

You are to write an assembly language procedure that MUST be placed in a file that is SEPARATE from the file holding the main program. This procedure, called DATELIST, must display the ID numbers from all records which contain a specified date. If any records are displayed, DATALIST must also display the number of records with the specified date, the total of the tally values from these records and the average of the tally values from these records. If there are no records for the specified date, DATELIST should display a message. DATELIST MUST assume that the array of records is sorted on date and MUST take advantage of that fact. DATELIST must take three arguments: the address of the array of records, the address of the date to look for, and the address of the number of records.

You must also write an assembly language main program that does the following steps in order.

  1. Calls LOAD to read in the records.
  2. Calls SORT to organize the records.
  3. Repeatedly prompts for a date and calls DATELIST to display the ID numbers from all records that contain that date and to display the associated statistics. The looping should continue until the entered date consists of nothing but a carriage return (Enter).

Hand in a .LIS listing of your main program and a .LIS listing of your procedure. Also, hand in a captured program execution (using CARBON) in which you run the program and enter the following dates: 01/01, 09/14, 10/10, 11/09, 12/15, 13/01.

Notes:

Do NOT attempt to display on your screen or print the 5DATA.DAT file. It is a binary file and will really mess up your terminal or produce a garbage printout.

Copy the LOAD.PAS and SORT98.C files from the PROJECT directory to your own directory. Do not copy the data file to your own directory (LOAD expects it to be in PROJECT).

To compile LOAD, enter the command PASCAL LOAD at the $ prompt.

To compile SORT98, enter the command CC SORT98 at the $ prompt.

Assuming you name the file with your main program P5.MAR and the file with DATELIST DATELIST.MAR and assemble them to form P5.OBJ and DATELIST.OBJ, respectively, then to link everything together, give the command
     LINK  P5,DATELIST,LOAD,SORT