Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //DIVDEC JOB 'SEZEN',CLASS=A,NOTIFY=&SYSUID,MSGCLASS=H,
- // MSGLEVEL=(1,1)
- // EXEC ASMACLG
- //C.SYSOUT DD SYSOUT=*
- //C.SYSIN DD *
- **********************************
- * DOES PACKED DECIMAL MATH ON *
- * A CHARACTER WHICH ... *
- * HAS A DECIMAL PLACE IN IT... *
- * PACKING A CHARACTER RESULTS IN *
- * 22.22 -> 22B22F WHICH IS BAD *
- * AND ANNOYING, SO WE EXTRACT *
- * THE NUMBERS AND DECIMALS THEN *
- * OVERWRITE THE DECIMAL PLACE *
- **********************************
- PRINT ON,NODATA,NOGEN PROGRAM ENTRY BEGIN
- DIV CSECT
- STM R14,R12,12(R13)
- BASR R12,R0 ESTABLISHING ADDRESSABILITY
- USING *,R12
- ST R13,SAVE+4 STORING CALLERS REGISTERS
- LA R13,SAVE
- **********************************
- * START OF PROGRAM *
- **********************************
- MAIN OPEN (FILEIN,(INPUT)) OPEN INPUT
- OPEN (FILEOUT,(OUTPUT)) OPEN OUTPUT
- **********************************
- * BEGIN MAIN LOOP!! *
- **********************************
- BEGIN EQU *
- GET FILEIN,NUMS GET NUMBERS
- * PACK
- MVC DEC1,PART12
- PACK PD1,FLOAT1 PACK OUR CHARACTERS
- MVC DEC2,PART22 DECIMAL IGNORED, I.E.
- PACK PD2,FLOAT2 [22].[22] = 2222 AS WE
- MVC DEC3,PART32 OVERWRITE DECIMAL CHAR
- MVC OUTDV1,DEC3 THUS ADDRS END AS 2222
- PUT FILEOUT,OUTDV1
- PACK PD3,FLOAT3
- * TEST
- AP TEST1,PD1 TESTING VALIDITY OF OUR PD'S
- PUT FILEOUT,=CL80'ADDED 1'
- AP TEST2,PD2
- PUT FILEOUT,=CL80'ADDED 2'
- AP TEST3,PD3
- PUT FILEOUT,=CL80'ADDED 3'
- * MATH
- ZAP AD1,PD1 MOVE PD1 IN PREPARATION
- SRP PD2,64-1,0 SHIFT PD2 RIGHT, RESULT=3.33
- AP AD1,PD2 ADD PD1 + PD2
- SRP PD3,64-2,0 SHIFT PD3 RIGHT, RESULT=4.44
- ZAP DD1,AD1 MOVE AD1 INTO DD1 (DIVIDEND)
- DP DD1,PD3 DIVIDE AD1 BY PD3
- ZAP DD2,REM GETTING THE SECOND DECIMAL
- ZAP PD32,PD3 MOVE DIVISOR TO ANOTHER ADDR
- SRP PD32,64-1,0 SHIFT DIVISOR GIVING .444
- DP DD2,PD32 DIVIDE 3.35 BY .444 GIVING
- * OUTPUT 7
- MVC OUTDV1,EDWD1
- ED OUTDV1,PD1 START EDITING RESULTS
- MVC OUTDV2,EDWD1 TO BE OUTPUTTED...
- ED OUTDV2,PD2
- MVC OUTDV3,EDWD1
- ED OUTDV3,PD3
- MVC OUTDV4,EDWD1
- ED OUTDV4,AD1
- MVC QUOT1,EDWDQ
- ED QUOT1,QUOT
- MVC QUOT2,EDWDQ
- ED QUOT2,QUOTA
- PUT FILEOUT,OUTMSG OUTPUT OUR MSG
- **********************************
- * FINISH PROGRAM *
- **********************************
- FINISH EQU *
- CLOSE FILEIN CLOSE FILES
- CLOSE FILEOUT
- L R13,SAVE+4 RETURN REGISTERS
- LM R14,R12,12(R13)
- LA R15,0
- BR R14 RETURN TO OS
- **********************************
- * INPUT FILE *
- **********************************
- FILEIN DCB DSORG=PS,MACRF=(GM),DDNAME=FILEIN,EODAD=FINISH, X
- RECFM=FB,LRECL=80
- RECIN DS CL80
- **********************************
- * OUTPUT FILE *
- **********************************
- FILEOUT DCB DSORG=PS,MACRF=(PM),DDNAME=FILEOUT,RECFM=FB,LRECL=80
- SAVE DS 18F
- LTORG
- *********************
- * PACKED DECIMALS *
- *********************
- PD1 DS PL3 PACKED DECIMALS...
- PD2 DS PL3
- PD3 DS PL3
- PD32 DS PL3
- AD1 DS PL3
- *********************
- * DIVISION AREA *
- *********************
- DD1 DS PL5
- ORG DD1
- QUOT DS PL2 QUOTENT #1
- REM DS PL3 REMAINDER #1
- OUT ,
- DD2 DS PL5 DIVISION AREA FOR DECIMAL
- ORG DD2 OF DIVISION AREA 1'S QUOT
- QUOTA DS PL2
- REMA DS PL3
- ORG ,
- *********************
- * OUTPUT MESSAGE *
- *********************
- OUTMSG DS CL80 OUT MSG
- ORG OUTMSG
- OUTDV1 DS CL6 OUTPUT IS:
- DC CL2' ' 1ST INPUT
- OUTDV2 DS CL6 2ND INPUT
- DC CL2' ' 3RD INPUT
- OUTDV3 DS CL6 1ST + 2ND
- DC CL2' ' (1ST + 2ND) / 3RD
- OUTDV4 DS CL6
- DC CL2' '
- OUTDV5 DS CL5
- ORG OUTDV5
- QUOT1 DS CL3
- DC CL1'.'
- QUOT2 DS CL3
- ORG , EDIT
- *******************
- * EDIT WORDS *
- *******************
- EDWD1 DC X'2020204B2020' EDIT WORD FOR INPUTS N OUT
- EDWDQ DC X'202120' EDIT WORD FOR QUOTENTS
- *******************
- * INPUTS *
- *******************
- NUMS DS CL80 OUR INPUTS
- ORG NUMS
- *******************
- * 1ST INPUT *
- *******************
- FLOAT1 DS CL4 INPUT 1
- ORG FLOAT1
- PART11 DS CL2 1ST HALF OF NUMBER
- DEC1 DS CL1 DECIMAL (IS OVERWRITTEN)
- PART12 DS CL2 2ND HALF OF NUMBER
- *******************
- * 2ND INPUT *
- *******************
- FLOAT2 DS CL4
- ORG FLOAT2 INPUT 2...
- PART21 DS CL1
- DEC2 DS CL1 ETC. ETC.
- PART22 DS CL3
- *******************
- * 3RD INPUT *
- *******************
- FLOAT3 DS CL5 INPUT 3......
- ORG FLOAT3
- PART31 DS CL1
- DEC3 DS CL1
- PART32 DS CL4
- ORG ,
- TEST1 DC PL4'0' OUR ADDR'S WE USE TO TEST
- TEST2 DC PL4'0' IF OUR CONVERTED PD'S
- TEST3 DC PL3'0' ARE VALID OR NOT
- ORG ,
- ************************
- * REGISTERS *
- ************************
- R0 EQU 0 REGISTERS
- R1 EQU 1
- R2 EQU 2
- R3 EQU 3
- R4 EQU 4
- R5 EQU 5
- R6 EQU 6
- R7 EQU 7
- R8 EQU 8
- R9 EQU 9
- R10 EQU 10
- R11 EQU 11
- R12 EQU 12
- R13 EQU 13
- R14 EQU 14
- R15 EQU 15
- END DIV
- /*
- //G.SYSUDUMP DD SYSOUT=*
- //G.FILEOUT DD SYSOUT=*
- //G.FILEIN DD *
- 22.223.3334.4444
- /*
- //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement