Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //DIVIS JOB 'SEZEN',CLASS=A,NOTIFY=&SYSUID,MSGCLASS=H,
- // MSGLEVEL=(1,1)
- // EXEC ASMACLG
- //C.SYSOUT DD SYSOUT=*
- //C.SYSIN DD *
- 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 I'M PRETTY SURE
- **********************************
- * START OF PROGRAM *
- **********************************
- MAIN OPEN (FILEIN,(INPUT)) OPEN INPUT
- OPEN (FILEOUT,(OUTPUT)) OPEN OUTPUT
- **********************************
- * BEGIN MAIN LOOP!! *
- **********************************
- BEGIN EQU *
- GET FILEIN,RECIN
- MVC IN1,RECIN GRAB OUR NUMBERS
- PACK PD1,NUM1
- PACK PD2,NUM2 PACK EM UP
- CP PD1,=P'0'
- BE ERROR
- CP PD2,=P'0'
- BE ERROR
- **********************************
- * MAIN CALCULATIONS *
- **********************************
- LOOP2 EQU *
- ZAP DIV1,PD1
- CP PD1,ACC IF ACC IS HIGHER THAN
- BL WRITE EITHER NUMBER, THEN WE
- CP PD2,ACC ARE CERTAINLY DONE.
- BL WRITE
- DP DIV1,ACC
- CP REM,=P'0'
- BE GOOD
- AP ACC,=P'1'
- B LOOP2
- GOOD EQU * JMP HERE IF 1ST NUM...
- ZAP DIV1,PD2 IS DIVISIBLE BY ACC
- DP DIV1,ACC DIVIDE PD2 BY ACC
- CP REM,=P'0'
- BE GOOD2 IF BOTH ARE DIVISIBLE BY ACC
- AP ACC,=P'1' IF ONLY THE FIRST IS
- B LOOP2
- GOOD2 EQU * BOTH NUMBERS DIVISIBLE
- ZAP GACC,ACC BY ACC.
- AP ACC,=P'1' ADDING ONE TWO ACCUMULATOR
- B LOOP2 BACK TO MAIN LOOP
- **************************
- * OUTPUT MESSAGE *
- **************************
- WRITE EQU *
- MVC OUTDV1,EDWD PACKED DEC -> CHARACTER
- ED OUTDV1,PD1
- MVC OUTDV2,EDWD
- ED OUTDV2,PD2
- MVC OUTDV3,EDWD
- ED OUTDV3,GACC
- PUT FILEOUT,OUTMSG WRITE OUR MESSAGE
- ZAP ACC,=P'2' RESET OUR ACCUMULATOR
- ZAP GACC,=P'0' RESET BEST KNOWN DIVISOR
- B BEGIN BACK TO THE BEGINNING!
- FINISH EQU *
- CLOSE FILEIN CLOSE FILES
- CLOSE FILEOUT
- ******** EXIT ********
- L R13,SAVE+4 RETURN REGISTERS
- LM R14,R12,12(R13)
- LA R15,0
- BR R14 RETURN TO OS
- ERROR EQU *
- PUT FILEOUT,=CL80'NO DIVISION BY 0.'
- B FINISH
- *********************************
- * 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
- *
- LTORG
- ACC DC PL3'1' ACCUMULATOR, START @ 1
- GACC DC PL3'0' OUR BEST-KNOWN DIVISOR
- EDWD DC X'2020202021' EDIT WORD
- *
- IN1 DS CL80 REDUNDANT TO 'RECIN'
- HPD1 DS PL3 BUT IT'S EASIER FOR ME
- HPD2 DS PL3 TO TRACK IN MY HEAD
- ORG IN1
- NUM1 DS CL3 OUR NUMBER WE GRAB FROM
- SPACES DS CL1 THE FILE.
- NUM2 DS CL3
- ORG ,
- *
- DIV2 DS PL3
- DIV1 DS PL7 OUR MAIN DIVISION AREA
- ORG DIV1
- QUOT DS PL4 QUOTIENT
- REM DS PL3 REMAINDER
- ORG ,
- BLANKS DS CL70' '
- *
- PD1 DS PL2 OUR FIRST NUMBER (PD)
- PD2 DS PL2 OUR SECOND NUMBER (PD)
- *******************************
- * OUTPUT MESSAGE *
- *******************************
- OUTMSG DS CL80
- ORG OUTMSG
- MSG1 DC CL13'1ST NUMBER: '
- OUTDV1 DS CL3 PD1
- SPACE1 DC CL2' '
- MSG2 DC CL13'2ND NUMBER: '
- OUTDV2 DS CL3 PD2
- SPACE2 DC CL2' '
- MSG3 DC CL21'GREATEST DIVISOR: '
- OUTDV3 DS CL8 GACC
- ORG ,
- *******************************
- * REGISTERS *
- *******************************
- SAVE DS 18F
- R0 EQU 0
- 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=*
- //SETVAR SET REGS=&SYSUID..TEST(REGS)
- //G.REGS DD DSN=®S,DISP=SHR
- //G.FILEIN DD *
- 250 750
- 020 030
- 045 025
- 959 343
- 004 444
- 000 343
- /*
- //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement