| CSCI 360 | Spring 2014 |
For this assignment, modify program 4 so that it uses internal subroutines to build and print a table of numbers. A routine to sort the table of numbers will also be added.
After the table has been built, the table should be sorted and then printed three times. The first printing should display all of the numbers. The second and third printings will display the multiples of a specific value that is passed into the PRINT routine.
The table is the same as in Program 4.
The input file has one extra record at the beginning of the file. The first record contains exactly two numbers. The first number is the multiple value for the second printing of the table. The second number is the multiple value for the third printing of the table. The remaining records in the file have the same data and format as the program 4 input file.
For example:
6 3 1 -2005 360 515 90 50 -1 114 240 172219 60205 3 7534 204914 141 0 606031 -419 218 111 ...
The first record from the above example input file shows that the second printing of the table should only display multiples of 6 and the third printing should only display multiples of 3.
For this assignment, code at least the following 4 routines:
This routine will control the flow of the program by:
The storage area for this routine is where the table, the fullword that holds the address of the next available entry in the table, the input buffer, and the report headers should be created.
This routine will put the information into the table and set the address of the next available spot in the table.
Input Parameters for BUILD:
Suggested logic for BUILD
Initialization: Get the parameters
Set the table pointer to 1st entry in table
Read the first record
While end of file has not been reached
Move the data from the input record to the table using an XDECI loop
Read the next record
Endwhile
Use the second input parameter to pass back the address of the next
available entry in the table
This routine will print the values in a table that are multiples of a passed in value.
As in program 4, the PRINT subroutine should display 7 values per line. However, it's possible that the last line of output could have less than 7 values.
Input Parameters for PRINT:
Suggested logic for PRINT
Initialization: Get the parameters and initialize any counters to 0
While end of the table has not been reached
Get a number from the table
If the number is a multiple of the passed in value
Put the number on the print line
If the print line is full
Write the print line
Clear the print line
Endif
Endif
Increment the table pointer to the next entry in the table
Endwhile
If there are numbers on the print line
Write the print line
Endif
This routine will sort the contents of the table using the SELECTION SORT algorithm that is given in the course notes. The records should be sorted in ASCENDING order.
Input Parameters for SORT:
Suggested logic for SORT
for TOP from start of table to end of table; one entry at a time
Set the Subscript of smallest entry to TOP
for Work subscript from TOP + 1 to end of table; one entry at a time
If key[Work subscript] < key[Subscript of smallest entry]
Set Subscript of smallest entry to Work Subscript
Endif
Endfor
Swap Table[TOP] and Table[Subscript of smallest entry]
Endfor
Each of the routines listed above must have a storage area, which should include an area where the register contents can be saved upon entry to the routine (using STM), and restored before exiting (using LM).
When calling BUILD, PRINT or SORT, pass parameters to the routine by placing the address of a parameter list in register 1, as convention. The parameter list should be in the form of an address constant:
parmlist DC A(parameter 1)
DC A(parameter 2)
Use register 11 as the return register from BUILD, PRINT and SORT.
Use the following JCL statement to specify the input file:
//FT05F001 DD DSN=KC02330.CSCI360.FILES(DATA5),DISP=SHR
Use line documentation, documentation boxes, TITLE, EJECT, and
SPACE as before. Don't forget that each subroutine MUST have its
own documentation box.
Use a multiple value of 1 to get the PRINT subroutine to display the contents of the entire table of numbers.
Hand in a copy of your source code AND a listing of the Marist output on Blackboard.
The output for the program should resemble the following:
The numbers - All
-999999 -9090 -8426 -2005 -517 -419 -89
-84 -80 -77 -1 0 1 3
6 9 12 15 27 50 58
62 89 90 111 114 118 121
131 141 218 240 250 306 360
402 464 515 516 5106 7534 9001
14789 60205 95220 172219 204914 312909 606031
The numbers - Multiples of 6
-9090 -84 0 6 12 90 114
240 306 360 402 516 5106 95220
The numbers - Multiples of 3
-999999 -9090 -84 0 3 6 9
12 15 27 90 111 114 141
240 306 360 402 516 5106 95220
312909
The page header for each listing of numbers should start at the top of a new page. The lines with the numbers should be single spaced.