Assignment 8
100 points
Overview
The data in this assignment deals with appointments for tutoring. You will write a program that will read the file. The data will be processed and put in a table. You will then XDUMP part of the table. After that, you should print out the table contents in a report. Next: sort the table in ascending order by ID Number and then print it again.
The data will be stored in a small number of bytes.
Input
The input to the program will be a file with an unknown number of records. Each record represents a single appointment and has the following format:
columns description ------- ----------- 1 - 8 ID Number ('R' followed by 7 digits) 9 - 12 not used (spaces) 13 - 20 Password (characters) 21 - 24 not used (spaces) 25 - 33 Day of the Week (characters) 34 - 37 not used (spaces) 38 - 42 Time of Day in HH:MM format using a 24-hour clock 43 - 46 not used (spaces) 47 - 49 Room Number (digits) 50 - 80 not used (spaces)
Use the following JCL statement to specify the input file:
//FT05F001 DD DSN=KC02314.SPRING20.CSCI360.HW8DATA,DISP=SHR
Otherwise the JCL is the same JCL we have been using.
Processing Requirements
The main program will carry out the following steps:
1. Call subroutine BUILD to read the file and store the data in a table.
2. Use XDUMP to print 60 bytes of the table in hex.
3. Call subroutine PRINT to print the contents of the table using appropriate page and column headings.
4. Call subroutine SORTID to sort the table in ascending order. The key field is ID Number.
5. Call subroutine PRINT again.
Structure of a table entry
The structure of a table entry is as follows, in this order:
Thus each table entry is 15 bytes long.
BUILD subroutine
The arguments for the BUILD subroutine are the address of the table and the address of a fullword where we will store the end-of-table address.
We are going to store the 7 digits of the ID number as a 4-byte binary value. In the table, these may or may not be on fullword boundaries. You may need PACK, CVB and STCM. (As every ID Number starts with 'R', we do not need to store the 'R'.)
We are going to store the Password using "XOR encryption" using the binary value of the ID as the key field.
The "XOR encryption" technique works like this: suppose we have a 4-byte binary number KEY and we want to encrypt a 4-byte variable called PHRASE. Then:
(encrypted form of PHRASE) = PHRASE XOR KEY
We will do this using the ID number (as a 4-byte binary value) as the key. Each Password is up to 8 bytes long, so we need to encrypt the first 4 bytes and then the last 4 bytes.
We are going to store the rest of the information in a compressed format:
To construct the 3-byte value, you will presumably have to use PACK and CVB, followed by shift and bitwise instructions, and then you can use STCM to put the value in the table.
PRINT subroutine
The arguments for the PRINT subroutine are the address of the table. the address of a fullword where we have stored the end-of-table address, and the address of a 24-byte caption to put in the page heading line (centered).
When we extract the data from the table to print it, we will need to decrypt the Password. This can be done by exactly the same method. If we have PHRASE and KEY as above:
(decrypted form of PHRASE) = (encrypted form of PHRASE) XOR KEY
When we need to recover the last three pieces of information from the 3-byte value, we can do the following:
To extract the other data from the table, you may need to use IC, ICM, CVD, etc.
When you print the ID number, don't forget to put the 'R' in front of it.
SORTID subroutine
The arguments for the SORTID subroutine are the address of the table and the address of a fullword where we have stored the end-of-table address.
We will sort the table in descending order using the ID Number field as the key for sorting.
The SORTID subroutine should use the sorting method known as "Bubble Sort". Here is a description:
Bubble Sort Algorithm I is a pointer initially to the first entry J is a pointer initially equal to I K is a pointer STOP is a pointer to the last entry Temp is a variable as large as a table entry Do While (I < STOP) J = I Do While (J < STOP) K = J Increment J If Key(J) < Key(K) Temp = Entry(J) Entry(J) = Entry(K) Entry(K) = Temp EndIf EndDo Decrement STOP EndDo
Here the Key is the ID Number in the table.
There may be ways to make the above algorithm more efficient.
Other Notes
Output
Aside from the XDUMP, there will be about two pages of output. There is no need to print a page number.
The table listing should have a page heading. There should be column headings, triple-spaced from the page heading.
When you print the Time of Day, print it in the format "HH:MM".
When you print the Day of the Week spell it out, as in "Friday".
The captions in the page heading should be something like: "Appointment Information" or "Appointment Information by ID Number".
The lines of appointment information should be double-spaced.