-
Notifications
You must be signed in to change notification settings - Fork 9
/
cogs16a.mlc
119 lines (119 loc) · 5.42 KB
/
cogs16a.mlc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
****************************************************************
* FILENAME: COGS16A.MLC *
* AUTHOR : Bill Qualls/z390 adaption by Anthony Delosa *
* SYSTEM : z390 V1703 *
* REMARKS : Determine nationwide dollar sales for *
* COGSWORTH INDUSTRIES. *
* This is a modification of COGS13A.MLC and *
* illustrates binary multiplication. *
****************************************************************
START 0
YREGS
BEGIN SUBENTRY
WTO 'COGS16A ... Begin execution'
BAL R10,SETUP
MAIN EQU *
CLI EOFSW,C'Y'
BE EOJ
BAL R10,PROCESS
B MAIN
EOJ EQU *
BAL R10,WRAPUP
WTO 'COGS16A ... Normal end of program'
RETURN
****************************************************************
* SETUP - Those things which happen one time only, *
* before any records are processed. *
****************************************************************
SETUP EQU *
ST R10,SVSETUP
OPEN (INVENTRY,INPUT) Input is EBCDIC, no CR/LF
BAL R10,READ
L R10,SVSETUP
BR R10
****************************************************************
* READ - Read a record. *
****************************************************************
READ EQU *
ST R10,SVREAD
GET INVENTRY,IREC Read a single product record
B READX
ATEND EQU *
MVI EOFSW,C'Y'
READX EQU *
L R10,SVREAD
BR R10
****************************************************************
* PROCESS - Those things which happen once per record. *
****************************************************************
PROCESS EQU *
ST R10,SVPROC
LH R3,ICALIF Determine total units
AH R3,IILL sold for this product
AH R3,IUTAH
AH R3,IWISC
MH R3,ISELL Multiply units by price
A R3,TOTAL Add total thus far
ST R3,TOTAL then save back.
BAL R10,READ
L R10,SVPROC
BR R10
****************************************************************
* WRAPUP - Those things which happen one time only, *
* after all records have been processed. *
****************************************************************
WRAPUP EQU *
ST R10,SVWRAP
L R3,TOTAL Must put it in a register
CVD R3,DBLWORD to convert it to packed.
ED ODOLLARS,DBLWORD+4
WTO MF=(E,OMSG)
CLOSE INVENTRY
L R10,SVWRAP
BR R10
****************************************************************
* Literals, if any, will go here *
****************************************************************
LTORG
****************************************************************
* File definitions *
****************************************************************
INVENTRY DCB LRECL=28,RECFM=F,MACRF=GM,EODAD=ATEND, X
DDNAME=INVNTBIN
****************************************************************
* RETURN ADDRESSES *
****************************************************************
SVSETUP DC F'0' SETUP
SVPROC DC F'0' PROCESS
SVREAD DC F'0' READ
SVWRAP DC F'0' WRAPUP
****************************************************************
* Miscellaneous field definitions *
****************************************************************
EOFSW DC CL1'N' End of file? (Y/N)
TOTAL DC F'0' Nationwide dollar sales
DBLWORD DC D'0'
****************************************************************
* Input record definition *
****************************************************************
DS 0H Force halfword alignment
IREC DS 0CL28 1-28 Inventory record
IDESC DS CL10 1-10 Product description
ICALIF DS H 11-12 Units sold in Calif
IILL DS H 13-14 Units sold in Illinois
IUTAH DS H 15-16 Units sold in Utah
IWISC DS H 17-18 Units sold in Wisconsin
IBEGIN DS H 19-20 Beginning inventory
IPURCH DS H 21-22 Purchases throughout year
IQOH DS H 23-24 Actual quantity on hand
ICOST DS H 25-26 Cost (each) 99V99
ISELL DS H 27-28 Sell for (each) 99V99
****************************************************************
* Output message definition *
****************************************************************
OMSG DS 0CL53
DC H'53'
DC H'0'
DC CL39'COGS16A ... Nationwide dollar sales are'
ODOLLARS DC XL10'4020206B2021204B2020' BZZ,ZZ9.99
END BEGIN