GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


A Paste by Anonymous
1
 
ASSIGN2  CSECT      
         USING ASSIGN2,15         Set 15 as base register         
         XPRNT THEAD,ETHEAD-THEAD Print table header 
         XPRNT CHEAD1,ECHEAD1-CHEAD1   Print column header
         XPRNT CHEAD2,ECHEAD2-CHEAD2   Print column header 2
         XREAD BUFFER,80          Priming read for loop
DO1      BC    B'0100',ENDDO1     Do while not 
         L     3,SUMCOUNT           Load the current record count
         A     3,=F'1'              Increment counter
         ST    3,SUMCOUNT           Store SUMCOUNT
*** Load and process first number ***
         XDECI 4,BUFFER             NUM1 -> gpr 4
         BC    B'0001',S0C1         Branch on bad input
         L     3,SUM1               Get current SUM1
         AR    3,4                  SUM1 += NUM1
         ST    3,SUM1               Store updated sum to SUM1
         XDECO 4,REC1               Put NUM1 in the record print line
         LR    5,4                  NUM1 -> gpr 5 (temp for calcs) 
         AR    5,5                   NUM1*2
         AR    5,5                   (NUM1*2)*2 = NUM1*4
         LR    6,5                   NUM1*4 -> gpr6
         AR    5,5                   (NUM1*4)*2 = NUM1*8
         AR    6,5                   (NUM1*4)+(NUM1*8)
         SR    6,4                   (NUM1*4)+(NUM1*8)-NUM1
         XDECO 6,REC1M11            Put NUM1*11 into record print line
         L     3,SUM1M11            Get current SUM1M11
         AR    3,6                  Add NUM1*11 to SUM1M11
         ST    3,SUM1M11            Store updated sum to SUM1M11
*** Load and process second number ***
         XDECI 4,0(,1)              NUM2 in record -> gpr 4
         BC    B'0001',S0C1         Branch on bad input
         L     3,SUM2               Get current SUM2
         AR    3,4                  Add NUM2 to SUM2
         ST    3,SUM2               Store updated sum to SUM2
         XDECO 4,REC2               Put NUM2 in the record print line
         AR    4,4                  NUM2*2 -> gpr 4
         LR    5,4                  NUM2*2 -> gpr 5 (temp for calcs) 
         AR    5,5                   (NUM2*2)*2 = NUM2*4          
         AR    5,5                   (NUM2*4)*2 = NUM2*8  
         LR    6,5                   NUM2*8 -> gpr 6   
         AR    5,5                   (NUM2*8)*2 = NUM2*16           
         LR    7,5                   NUM2*16 -> gpr 7
         SR    7,4                   (NUM2*16)-(NUM2*2)
         AR    7,6                   (NUM2*16)-(NUM2*2)+(NUM2*8)
         XDECO 7,REC2M22            Put NUM2*22 into record print line
         L     3,SUM2M22            Get current SUM2M22
         AR    3,7                  Add NUM2*22 to SUM2M22
         ST    3,SUM2M22            Store updated sum to SUM2M22         
*** Output record line ***
         XPRNT RLINE,ENDRLINE-RLINE Print record line
         XREAD BUFFER,80            Attempt to read next line
         B     DO1                  Branch to top of loop
ENDDO1   DS    0C                 End of Do
         L     3,SUMCOUNT         Load SUMCOUNT to gpr 3
         XDECO 3,RECORDS          Put SUMCOUNT count in RECORDS
         XPRNT RCOUNT,ERCOUNT-RCOUNT Print record count line
*** Print Sum header and Sums ***
         XPRNT SHEAD,ESHEAD-SHEAD Print Sum header line
         L     3,SUM1             Load SUM1 to gpr 3
         XDECO 3,REC1             Put SUM1 in record output line
         L     3,SUM1M11          Load SUM1M11 to gpr 3
         XDECO 3,REC1M11          Put SUM1M11 in record output line
         L     3,SUM2             Load SUM2 to gpr 3
         XDECO 3,REC2             Put SUM2 in record output line
         L     3,SUM2M22          Load SUM2M22 to gpr 3
         XDECO 3,REC2M22          Put SUM2M22 in record output line
         XPRNT RLINE,ENDRLINE-RLINE Print record line
         BCR   B'1111',14         Return control to OS
*
S0C1     DC    H'0'               Cause S0C1 ABEND on bad read
BUFFER   DS    CL80
*** SUM STORAGE ***
SUM1     DC    F'0'
SUM1M11  DC    F'0'
SUM2     DC    F'0'
SUM2M22  DC    F'0'
SUMCOUNT DC    F'0'
*** TABLE HEADER ***
THEAD    DC    CL1'1'             Top of Page
         DC    CL46'MULTIPLICATION BY COMBINING VARIOUS ADDITIONS'
ETHEAD   DS    0C                 End of table header
*** COLUMN HEADER1 ***
CHEAD1   DC    CL1'-'             Triple Spacing
         DC    CL49'        NUM1     NUM1*11        NUM2     NUM2*22'
ECHEAD1  DS    0C                 End Column Header
*** COLUMN HEADER2 ***
CHEAD2   DC    CL1' '             Single Spacing
         DC    CL49'                 (8+4-1)                (16-2+8)'
ECHEAD2  DS    0C                 End 2nd Column Header
*** SUM HEADER ***
SHEAD    DC    CL1'0'             Double Spacing
         DC    CL49'        SUM1     SUM1*11        SUM2     SUM2*22'
ESHEAD   DS    0C                 End Sum Header
*** RECORD PRINTING LINE ***
RLINE    DC    CL1'0'             Double spacing
REC1     DS    CL12               Field for first record
REC1M11  DS    CL12               Field for second record
REC2     DS    CL12               Field for third record
REC2M22  DS    CL12               Field for fourth record
ENDRLINE DS    0C                 End of record print line
*** RECORD COUNT LINE ***
RCOUNT   DC    CL1'-'             Triple spacing
         DC    CL29'NUMBER OF RECORDS PROCESSED ='
RECORDS  DS    CL12               Storage for record count
ERCOUNT  DS    0C                 End of record count line
         END   ASSIGN2