Assignment 2 80 points For this assignment you will write a program that reads i
ID: 3789262 • Letter: A
Question
Assignment 2
80 points
For this assignment you will write a program that reads in an unknown number of lines, each containing 5-digit numbers, 3 per line. For each line read, print out the numbers X, Y and Z, calculate the value of Z - X + Y and print the result.
Each line has the following format:
When all processing is done, print the sum of the result values from all of the lines and the number of lines read.
Program incrementally! That means that you should begin by just reading one record and print out those numbers. When that works, put in a loop. If you get one part working before moving on to the next, your debugging will be much easier and less time-consuming.
Use a top driven loop:
You will need to put labels on two lines, one for the top of the loop and one for the bottom of the loop. You can actually put a label on any line of code, but many people put them on lines that don't do anything else, like this:
Here DS 0H takes up no space. (It declares 0 halfwords on a halfword boundary, and as each instruction is an even number of bytes, the location will already be on a halfword boundary.)
JCL for this assignment
Use the following JCL:
As before, you will need to replace "Your Name" with your own name, and you will need to replace "KCnumber" with your own logon ID.
Your actual code should be after the comment box and before the /* line.
Data
As indicated above, the data is listed in the source code file between the FT05FT001 line and the following /* line.
This is known as instream or inline data. It is also possible to read from a specific disk file.
Other requirements
In the JCL, at the very beginning of the program is a comment box. Notice the place that says "Register Usage". Make a list here of registers you used and how you made use of each one. For instance, you will be using register 15 as your base register, and register 1 is used by XDECI. Thus you might have:
and probably several more such lines.
The comment box should also list your name and the number of the assignment (Assignment 2).
To use XREAD, you will need to have an 80-byte field to contain each line you read.
To produce the output, you will need to define a couple of output lines containing DC and DS statements (with labels on the DS statements).
Your program should include line documentation. At the end of each line (certainly for most lines) skip one or more spaces and insert a few words describing what that instruction does. Try to line these up so they start in the same column. For instance:
If you wish, you may use register equates. These allow you to refer to register 3 as "R3" instead of just "3". To use these, include lines such as
somewhere in your program file (such as at the end). You can read about EQU in our textbook, section 2.11, or on one of the web pages. One advantage of using the register equates is that you are reminded that a number representing a register does just that and does not have some other meaning. You are not required to use the register equates.
Name your program file something like "ASSIGN2".
Submit your program file and output file through Blackboard.
Program 2 Output
Here is output for Programming Assignment 2 using 96-space print lines: a carriage control character and 95 more bytes. Here the carriage control characters have not been interpreted and you can see them in the first column.
You should have the same numbers. You may use a wider line if you like.
Explanation / Answer
/KCnumberA JOB ,'Your Name',MSGCLASS=H //STEP1 EXEC PGM=ASSIST //STEPLIB DD DSN=KC02293.ASSIST.LOADLIB,DISP=SHR //SYSPRINT DD SYSOUT=* //SYSIN DD * ************************************************************ * * Program: ASSIGN2 * Programmer: Your Name * * Register usage: * ************************************************************ OUTFIL NUMS=T2,ENDREC=10 SUBSET FROM(IN) TO(OUT) KEEP INPUT NUMS(10) M(10) /* //FT05F001 DD * 3 7 12 45700 -2230 9 0 +87 2 85316 28253 0 00120 0 3245 55029 69177 10681 10130 250 -85 0 3364 52751 -8787 11100 22923 12345 84467 -4591 -789 -7 23 18513 54009 25384 /* //FT06F001 DD SYSOUT=* //