*M*      POS      HANDLES THE POSITIONING CALS,PFIL, PRECORD, WEOF, REW.
*P*      NAME:    POS
*,*      PURPOSE  RECEIVES AND HANDLES THE POSITIONING CALS, PFIL,
*,*               PRECORD, WEOF, REW.
*,*      DESCRIPTION IN GENERAL, FOR EACH CAL THE DCB IS CHECKED FOR
*,*               OPEN, THE ASSIGNMENT OF THE DCB IS THEN USED TO
*,*               SWITCH TO THE APPROPRIATE ROUTINE WHERE THE FUNCTION
*,*               IS PERFORMED.
MONPROC  SET      1
ANSPROC  SET      1
         SYSTEM   UTS
         DEF      POS:              PATCHIG DEF
POS:     RES
         PAGE
K2       EQU      2
K400     EQU      X'400'
K7FFF    EQU      X'7FFF'
K7       EQU      X'7'
KD       EQU      X'D'
K0F      EQU      X'F'
K0C      EQU      X'0C'
K0E      EQU      X'0E'
K0       EQU      X'0'
K1       EQU      X'1'
K4       EQU      X'4'
KA       EQU      X'A'
K10      EQU      X'10'
K50      EQU      X'50'
K1000    EQU      X'1000'
K1FFFF   EQU      X'1FFFF'
W14      EQU      14
W19      EQU      19
         PAGE
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
SR1      EQU      8
SR2      EQU      9
SR3      EQU      10
SR4      EQU      11
D1       EQU      12
D2       EQU      13
D3       EQU      14
D4       EQU      15
         PAGE     POS DEFS
******************  DEF  *******************
*
************ROUTINES************
         DEF      PEOF              POSITION TO END OF FILE
         DEF      PFIL              HANDLE M:PFIL
         DEF      PLEOFRM           POSITION LABEL TAPE TO EOF
         DEF      PRECORD           HANDLE M:PRECORD
         DEF      REW               HANDLE M:REW
         DEF      WEOF              HANDLE M:WEOF
         SPACE    5
****************  REF  *******************
*
************CONSTANTS************
         REF      CLSSEG
         REF      DOUBLEZERO
         REF      E:NQW
         REF      J:JIT
         REF      LBLTSEG
         REF      M24
         REF      M6
         REF      NBATAPE
         REF      OPNSEG
         REF      OPNTPSEG
         REF      XFF
         REF      YFF
         REF      YFFFF
         REF      Y000C
         REF      Y0008
         REF      Y001
         REF      Y002
         REF      Y08
         REF      Y1
         REF      Y2
         REF      Y8
         REF      NB31TO0           TABLE NBITS
         SPACE    2
***************VARIABLES**********
         REF      ABO               OUTPUT;
         REF      AVRSID            INPUT; OUTPUT;
         REF      AVRTBL            INPUT;BITS32-63 OUTPUT;BITS32-63
         REF      ERO               OUTPUT;
         REF      J:BASE            INPUT; OUTPUT;
         REF      J:USCDX           INPUT;
         REF      TB:FLGS           INPUT;BITS0-1
         SPACE    2
***************ROUTINES************
         REF      CBB5              FLUSH AND RELEASE BLOCKING BUFFER
         REF      CHKANS0           SKIP IF DCB NOT ANS
         REF      CHKANS1           SKIP IF DCB ANS
         REF      CHKBIT            GET NEXT FPT PARAM
         REF      CHKBIT1           GET FIRST FPT PARAM
         REF      CLSLBL#           FIND FILE ON PREVIOUS VOLUME
         REF      DONEWQP           DO ASYNCHRONOUS RECORD SPACING
         REF      ESTABBUF          RELOAD INDEX BUFFER
         REF      FNDKYT            FIND PRECEEDING KEY
         REF      GETASN            GET DCB:ASN
         REF      GETFUN            GET DCB:FUN
         REF      GETSEC            GET BUFFER FOR MI
         REF      GETTYC            GET DCB:TYC
         REF      IOSDEV            DO 'TOP OF FORMS' TO PRINTER
         REF      IOSPIN            WAIT FOR I/O COMPLETE
         REF      MSREXIT           NORMAL EXIT
         REF      MSRWRTX           NORMAL EXIT, CLEAR SR1, SR3
         REF      MSR01EXIT         ABN/ERR EXIT
         REF      PRDCRD11          SKIP KEYED FILE RECORDS
         REF      PRECEA            END ACTION FOR DONEWQP
         REF      PULLALLEXIT       GENERAL EXIT ROUTINE
         REF      PUNWEOF           WRITE !EOD ON CARD PUNCH.
         REF      PUSHALL           GENERAL ENVIRONMENT SAVE
         REF      REDSEC            READ MI BLOCK
         REF      SETCMD1           SET DCB:CMD
         REF      SETLKEYUB         SET LAST KEY FLAG
         REF      SETTYC            SET DCB:TYC
         REF      T:REG             SLEEP WHILE PRECORD IS DONE
         REF      TAPEOP            DO TAPE I/O OPERATION
         REF      TRUNC             TRUNCATE BUFFER
         BOUND    8
PTL      EQU      %
         GEN,8,16,8 X'80',0,X'10'
         DATA     2
PTV      GEN,8,16,8  X'80',0,X'80'
         DATA     2
REWMSK   DATA     X'9FFFFFFF'
         PAGE
SKFILE   EQU      %                 SKIP FILE FORWARD
         LI,SR3   K0C
SKFILE1  EQU      %
         BAL,SR4  GETAVR
         AI,R1    1                 INCR TM COUNT
PREOP    STD,R0   AVRTBL,R3
*D*      NAME:    PREOP
*,*      ENTRY    SKFILE, SKFILER, REWTP, SKREC, WRTEOF
*,*      REGISTERS ALL VOLATILE
*,*      CALL     BAL,SR2 NAME
*,*      DESCRIPTION ROUTINES PERFORM TAPE OPERATIONS, (SKFILE=SPACE
*,*               FILE FORWARD, SKFILER=SPACE FILE BACK, REWTP=REWIND,
*,*               SKREC=SKIP RECORD FORE OR BACK PER DCB:DIR), AND DO
*,*               ANY NECESSARY ADJUSTING OF AVRTBL:TPOS. ALL PASS THRU
*,*               PREOP WHICH IS THE GENERALIZED ENTRY FOR ANY  TAPE
*,*               OPERATION SPECIFIED IN SR3.
         INT,R0   RNR,R6  CLR R0 BYTE 0, RNR TO CC2
         LW,R1    Y2                EIC. LW DOES NOT DISTURB CC2
         BCR,4    %+2              TEST CC29 IS RNR ON
         AW,R1    Y1                YES. MERGE EVC
         STS,R0   ORG,R6            CLEAR EIC & IF RNR ON, EVC TOO
         B        TAPEOP
SKFILER  EQU      %
         LI,SR3   KD
         BAL,SR4  GETAVR
         CI,R1    X'FFFF'
         BAZ      %+2               NEVER GO NEG
         AI,R1    -1                DECR TM COUNT
         B        PREOP
REWTP    EQU      %                 REWIND TAPE
         LI,SR3   K0E
         BAL,SR4  GETAVR
         AND,R1   YFFFF             CLEAR TM COUNT
         B        PREOP
SKREC    EQU      %
         LI,SR3   K400
         AND,SR3  DIR,R6
         SLS,SR3  -10
         LCW,SR3  SR3               FSR=5,BSR=4
         AI,SR3   5
         LW,15    NVA,6             # RECORDS
         LI,0     PRECEA
         B        DONEWQP
WRTEOF   LI,SR3   X'F'
         LI,SR4   SKFILE1
*
GETAVR   LW,3     DSI,6
         AND,3    XFF               DCTX
         AI,R3    NBATAPE
         LD,R0    AVRTBL,R3
         B        *SR4
         SPACE    3
SETEOPZ  EQU      %
         LI,D1    K0
SETEOP   EQU      %
         LW,D2    Y000C
         STS,D1   EOP,R6
         B        *R0
         PAGE
TESTOPN  EQU      %
*D*      NAME:    TESTOPN
*,*      REGISTERS VOLATILE EXCEPT R6,R7
*,*      DESCRIPTION DOES NO PARAMETER OPEN OF DCB IF NOT ALREADY OPEN.
*,*               EXITS TO MSRWRTX IF ASN=DEVICE AND NOT TAPE AND NOT
*,*               WEOF COMMAND OR IF ASN=DISK AND ORG =RANDOM. RETURNS
*,*               ON ALL OTHER COMBINATIONS.
         BAL,R1   PUSHALL           SEE IF DCB IS OPEN
         LW,D2    Y002
         AND,D2   FCD,R6
         BNEZ     TSTOPX            ---> DCB ALREADY OPEN.
         LW,R5    J:BASE              SAVE POINTER TO USER R0.
         LI,R7    DOUBLEZERO+1
         OVERLAY  OPNSEG,0
         STW,R5   J:BASE              RESTORE POINTER TO USER R0.
         LW,R1    Y002
         CW,R1    FCD,R6              DID DCB GET OPENED...
         BAZ      PXX               ---> NO. DESTRUCT & REPORT ERROR.
         LW,R1    TSTACK
         LCI      7
         LM,R5    -7,R1
TSTOPX   LI,R4    7
         AND,R4   ASN,R6            R4 = DCB:ASN
         CI,R4    3
         BLE      TSTVEC,R4
TSTVEC   B        MSRWRTXX          --->JRNL. NO POSITIONING.
         B        TSTORG            --->FILE. SEE IF RANDOM.
         B        *SR1              --->ANS/LBLT. RETURN.
*                                   --->DEVICE.
         CI,SR1   WEOF+1
         BE       WEOF+1
         BAL,1    TCHK
         BCR,8    MSRWRTXX          NOT TAPE
         BCS,4    MSRWRTXX          NOT TAPE
         B        *SR1              TAPE.
*
TSTORG   LI,R1    X'30'
         AND,R1   ORG,R6
         CI,R1    X'30'
         BE       MSRWRTX           RAND FOR DISK
         B        *SR1
         PAGE     PFIL
*                                   POSITION TO BEGINNING OR END OF FILE
*
*
PFIL     EQU      %
*F*      NAME:    PFIL
*,*      PURPOSE  HANDLES THE PFIL CAL
*,*      DESCRIPTION POSITIONS THE FILE TO ITS BEGINNING OR END, AS
*,*               REQUESTED, OR SKIPS DEVICE TAPE FORWARD OR BACK ONE
*,*               TAPE MARK.
         SPACE    3
*D*      NAME:    PFIL
*,*      INTERFACE TESTOPN, SKFILE, SKFILER, GETSEC, REDSEC, TRUNC,
*,*               ESTABBUF, FNDKYT, SETLKEYUB, SETCMD1, IOSPIN, CHKANS0,
*,*               MSREXIT, CLSLBL, PULLALLEXIT, POSCHKEOF, MSR01EXIT,
*,*               CBB5
*,*      DESCRIPTION IF THE DCB IS ASSIGNED TO DEVICE, A SKIP FILE
*,*               (TAPE MARK) FORWARDOR BACKWARD IS PERFORMED FOR THE
*,*               OPTION OF EOF OR BOF, RESPECTIVELLY.
*,*               IF THE DCB IS ASSIGNED TO ANS TAPE AND THE BOF OPTION IS
*,*               USED, NO OPERATION IS PERFORMED. FOR ALL OTHER CASES
*,*               THE FILE IS POSITIONED EITHER BEFORE THE FIRST RECORD(BOF)
*,*               OR AFTER THE LAST DATA RECORD. IN THE CASE OF TAPE, THIS
*,*               CAN RESULT IN SWITCHING TO A NEW VOLUME IF THE FILE
*,*               IS NOT COMPLETE ON ONE VOLUME.
         BAL,SR1  TESTOPN
         CI,R4    3                   IS DEVICE...
         BNE      PFIL1             *NO, FILE OR LABEL TAPE
         LI,SR2   PRECORDX          RETURN ADDRESS
         LI,D2    K10
         STW,D2   NVA,R6
         AND,D2   0,R7
         BEZ      SKFILE            SKIP FILE FORWARD
         B        SKFILER           SKIP FILE REVERSE
PFIL1    EQU      %
         CI,R4    2                 IS IT LABEL
         BE       PFIL4
*                                   POSITION TO BEGINNING OR END OF FILE
*                                   ON DISK OR LABELED TAPE
         LI,R3    K10
         AND,R3   0,R7
         BNEZ     PFILB             BOF DESIRED
*                                   EOF DESIRED
PEOF     RES      0
         BAL,SR1  TSTORG              DON'T RETURN IF RANDOM.
         LI,SR1   X'20'
         CW,SR1   ORG,6
         BANZ     PEOF1
         LW,1     CFU,6
         LW,R3    TDA,1             GET LAST REC #
SEQ3     SW,R3    W14,6             CURRENT REC #
         STW,R3   W19,6             SET # RECS TO BE SKIPPED
         B        PFILB2            GET OUT
PEOF1    RES      0
*
         BAL,R0   GETSEC            MI BUFFER
         LW,D1    LDA,R1            LAST LVL 0
         BEZ      PEOFZ             NO LAST
         BAL,R0   REDSEC            READ LAST GRANULE
         LW,D1    BUFF2+FLINK       GET FLINK
         BEZ      PFILD2             LAST
PEOFZ    BAL,SR4  TRUNC             CLR & REL BFR
         BAL,R0   ESTABBUF          GET SECTOR BUFFER
         B        PFILE2
PFILD1   EQU      %
         LW,D1    BUFF2+FLINK       GET FLINK
         BEZ      PFILD2            YES
         BAL,R0   REDSEC            NO--READ IN NEXT GRANULE
         B        PFILD1
PFILD2   EQU      %
         LH,R3    BUFF2+NAVX        GET NAV
         BAL,R0   FNDKYT
         B        PRECORDX
         BAL,R0  SETLKEYUB
PFILE2   EQU      %
         B        PFILB2
*
PFILB    EQU      %
         LI,R3    X'20'
         AND,R3   ORG,6
         BEZ      SEQ3              CONSECUTIVE
*
         LI,R3    K0                SET CMD = 0
         BAL,R0   SETCMD1
PFILB2   EQU      %
         LI,D1    K0
         BAL,R0   SETTYC
         B        PRECORDX
*
*
PFIL4    EQU      %
*                                   POSITION LABELED TAPE
         BAL,SR4  IOSPIN
         LI,R3    K10
         AND,R3   0,R7
         BEZ      PLEOF
*                                   BOF
         BAL,R0   CHKANS0           NO PFIL FOR ANS BOF
         B        MSREXIT
         LW,R0    SCR,R6           SAVE IMPT DCB ENTRIES
         LW,R1    ACD,R6
         PUSH     2,R0
         LD,R0    PTL
         PUSH     2,R0
         LW,R7    TSTACK
         AI,R7    -1
         LI,SR4   PLBOF
         REMEMBER
         BAL,R1   PUSHALL
         OVERTO   OPNTPSEG,CLSLBL#
PLBOF    EQU      %
         PULL     2,R0
         PULL     2,R0
         AI,SR3   0
         BEZ      %+3
PXX      EQU      %
         DESTRUCT PULLALLEXIT
         STW,R0   SCR,R6
         STW,R1   ACD,R6
         BAL,SR2  SKFILE
         BAL,SR2  SKFILE
         BAL,SR4  GETAVR
         AND,R1   NB31TO0+27
         AI,R1    X'10000'
         STD,R0   AVRTBL,R3
*
         LW,R1    Y002
         STS,R1   FCD,R6
         LI,R0    K0
         LW,R1    KBUF,R6
         STW,R0   0,R1
         B        PRECORDX
*
PLEOF    EQU      %
*                                   GO TO EOF
         LW,R1    Y0008
         CW,R1    EOP,R6
         BANZ     PRECORDX1
         LI,R0    0                 TELL CHKEOF THAT FROM PFIL
         LW,R1    M24
         STS,R0   BLKCNT,R6
         LW,R1    Y08               AVOID POSSIBLE PROBLEM
ULBL    EQU  5
         STS,R0   ULBL,R6
PLEOF1   EQU      %
PLEOFRM  RES      0
         BAL,SR2  SKFILE
         OVERLAY  LBLTSEG,5
         CI,9     -1
         BNE      PLEOF2
         LW,SR2   Y002              CHECK DCB OPEN
         CW,SR2   FCD,R6
         BANZ     PLEOF1            YES-CVOL WAS OK
*
*E*      ERROR:   56 - 00  CVOL ERROR DURING TAPE POSITIONING
*
         LI,SR3   X'56'
         B        MSR01EXIT         CVOL BLEW IT
PLEOF2   EQU      %
         BAL,R0   CLRBBUFL
         LI,R0    K0
         LI,R1    X'E0000'
         STS,R0   BFL,R6
         B        PRECORDX
CLRBBUFL EQU      %
         PUSH     8,D1
         B        CBB5
         PAGE     REW
*                                   REWIND DISK,LABELED TAPE FILES AND
*                                   UNLABELED TAPES
*
*
REW      EQU      %
*F*      NAME:    REW
*,*      PURPOSE  HANDLES THE REW CAL.
*,*      DESCRIPTION IF THE DCB IS CLOSED AND IS NOT ASSIGNED TO DEVICE,
*,*               NO OPERATION IS PERFORMED. OTHERWISE, THE DCB IS OPENNED
*,*               IF NECESSARY. IF THE DCB IS ASSIGNED TO ANS TAPE, THE
*,*               TAPE IS CLOSED WITH THE PTV OPTION, I.E., POSITIONED
*,*               FOLLOWING THE VOL1 LABEL ON THAT VOLUME.
*,*               FOR OTHER ASSIGNMENTS THE FILE IS POSITIONED TO BOF VIA
*,*               THE PFIL-BOF ROUTINE.
         SPACE    2
*D*      NAME:    REW
*,*      INTERFACE TESTOPN, CHKANS1, PULLALLEXIT, MSRCLS, REWT
*,*      DESCRIPTION IF THE DCB IS CLOSED AND IS NOT ASSIGNED TO DEVICE,
*,*               NO OPERATION IS PERFORMED. OTHERWISE, THE DCB IS OPENNED
*,*               IF NECESSARY. IF THE DCB IS ASSIGNED TO ANS TAPE, THE
*,*               TAPE IS CLOSED WITH THE PTV OPTION, I.E., POSITIONED
*,*               FOLLOWING THE VOL1 LABEL ON THAT VOLUME.
*,*               FOR OTHER ASSIGNMENTS THE FILE IS POSITIONED TO BOF VIA
*,*               THE PFIL-BOF ROUTINE.
         CLEAR
         LW,R1    Y002
         CW,R1    FCD,R6
         BANZ     REW4              ITS OPEN
         BAL,R1   JASN              TISNT, IS IT A DEVICE
         DESTRUCT                   NO, GIVE UP
REW4     EQU      %
         BAL,SR1  TESTOPN
         BAL,R0   CHKANS1
         B        REW5              NOT ANS
         LD,R0    PTV               POSITION TO VOLUME
         PUSH     2,R0
         LW,R7    TSTACK
         AI,R7    -1
         LI,SR4   PULLALLEXIT
         OVERTO   CLSSEG,0          CLOSE AT MSRCLS
REW5     LI,R7    PTL
         BAL,1    JASN
         B        PFIL1
*                                   BOF
         LW,SR2   Y8
         XW,SR2   NVA,R6
         BGEZ     %+4               LAST NOT REW
         LW,SR2   Y000C
         CW,SR2   EOP,R6
         BAZ      %+2               SKIP MULT REWS
         BAL,SR2  REWTP             MT DEVICE--REWIND
         BAL,SR4  GETAVR
         AND,R1   REWMSK                                                720
         STD,R0   AVRTBL,R3
         B        PRECORDX
         PAGE     WEOF
*                                   WRITE END OF FILE ON UNLABELED TAPES
*                                   R5 =JIT ADR
*                                   R7 =PLIST ADR
*                                   SR1 = OPCODE
*                                   BAL,SR4 WEOF
WEOF     EQU      %
*F*      NAME:    WEOF
*,*      PURPOSE  HANDLES THE WEOF CAL.
*,*      DESCRIPTION IF THE DCB IS NOT OPEN, IT IS OPENNED. IF THE DCB
*,*               IS NOT ASSIGNED TO DEVICE OR IS OPEN IN, NO OPERATION
*,*               IS PERFORMED. OTHERWISE, IF TAPE, A TAPE MARK IS WRITTEN,
*,*               OR FOR OTHER DEVICES A !EOD RECORD IS WRITTEN.
         SPACE    2
*D*      NAME:    WEOF
*,*      INTERFACE CHKANS0, GETFUN, MSRWRTX, WRTEOF, RWPUNCC
*,*      DESCRIPTION IF THE DCB IS NOT OPEN, IT IS OPENNED. IF THE DCB
*,*               IS NOT ASSIGNED TO DEVICE OR IS OPEN IN, NO OPERATION
*,*               IS PERFORMED. OTHERWISE, IF TAPE, A TAPE MARK IS WRITTEN,
*,*               OR FOR OTHER DEVICES A !EOD RECORD IS WRITTEN.
         BAL,SR1  TESTOPN
         CI,R4    3
         BNE      MSRWRTXX          --->NOT DEVICE; DO NOTHING.
         BAL,D2   GETFUN
         CI,D1    K1
         BE       MSRWRTXX
         BAL,R1   TCHK                GET CC=TB:FLGS; R2=C.B.ADDR
*                                   *TTIO IN CC.. TYPE,IN,OUT.
         BCR,1    MSRWRTXX          *XXX0 NOT OUT; DO NOTHING.
         BCR,12   WEOFCP            *00X1 MAY BE CARD PUNCH.
         BCR,8    WEOFTOF           *01X1 LIST; WRITE TOF.
         BCR,4    WEOFTAPE          *10X1 TAPE; WRITE TAPEMARK.
         B        MSRWRTXX          *11X1 DISC; DO NOTHING.
*
WEOFCP   EQU      %
         LW,R5    R2                R5 = C.B. POINTER OR ZERO.
         BEZ      WEOFCP1
         CI,R3    X'20'               SYMBIONT DEVICE. IS IT C.P....
         BANZ     WEOFCP2           --->YES. PUNCH EOD.
         B        MSRWRTXX          --->NO. DO NOTHING.
WEOFCP1  CI,R3    X'10'               NONSYMBIONT.
         BE       MSRWRTXX          ---> DO NOTHING TO 'ME'.
         CI,R3    0
         BE       MSRWRTXX          ---> DO NOTHING TO 'NO'.
WEOFCP2  BAL,R0   PUNWEOF             WRITE !EOD TO CARD PUNCH.
         B        WEOFX             ---> SET EOP WRITE & EXIT.
*
WEOFTAPE EQU      %
         BAL,SR2  WRTEOF              TAPE. WRITE TAPE MARK.
         STW,SR2  NVA,R6              SET NVA POSITIVE.
         B        PRECORDX          ---> SET EOP ZERO & EXIT.
*
WEOFTOF  EQU      %
         LI,SR1   X'04'
         BAL,SR4  IOSDEV              LISTING. SKIP TO TOP-OF-FORM.
WEOFX    EQU      %
         LW,D1    Y0008
         BAL,R0   SETEOP                 SET EOP WRITE.
         B        PRECORDX1         ---> AND EXIT.
         PAGE
JASN     BAL,0    GETASN            D2
         CI,D2    3                 DEVICE
         BNE      0,1
         B        1,1
*
TCHK     EQU      %
         LI,R2    X'F'
         AND,R2   CLK,R6              IS DCB SYMBIONT...
         BEZ      TCHK1             --->NO.  (R2=0).
         LW,R2    *J:USCDX,R2         YES. R2= C.B. POINTER.
         BEZ      TCHK1             --->*** SHOULDN'T HAPPEN.***
         LW,R3    1,R2
         SCS,R3   16                R3(0-7)=FLAGS FOR DEVICE.
         LC       R3                CC = FLAGS FOR SYMBIONT DEVICE.
         B        0,R1              ---> RETURN TO CALLER.
TCHK1    EQU      %
         LI,3     BADEVTP
         LB,3     *6,3
         AND,3    M6
         LC       TB:FLGS,3
         B        0,R1
         PAGE     PRECORD
*                                   THIS ROUTINE SKIPS THE SPECIFIED
*                                   NUMBER OF RECORDS FORWARD OR BACKWRD
*                                   ON TAPE AND DISK FILES
*                                   R5 = JIT
*                                   R6 = DCB
*                                   R7 = PLIST
*                                   SR1 = OPCODE
*                                   CALLING SEQ--BAL,SR4   PRECORD
PRECORD  EQU      %
*F*      NAME:    PRECORD
*,*      PURPOSE  HANDLES THE PRECORD CAL.
*,*      DESCRIPTION IF THE DCB IS NOT OPEN, IT IS OPENNED. IF AN ANS
*,*               TAPE, NO OPERATION IS PERFORMED. FOR DEVICE TAPE, THE
*,*               SPECIFIED NUMBER OF RECORDS IN THE APPROPRIATE DIRECTION
*,*               ARE SKIPPED WITH A SINGLE CALL TO IOQ THAT INCLUDES
*,*               THE NUMBER OF REPEATS. FOR LABEL TAPE, READL IN RDL IS
*,*               CALLED TO PERFORM A READ OR READ REVERSE, AS APPROPRIATE,
*,*               OF ZERO BYTES, THE CALL BEING REPEATED THE NUMBER OF
*,*               TIMES NECESSARY . FOR SEQUENTIAL DISK FILES, THE NUMBER
*,*               OF RECORDS TO SKIP, NOT EXCEEDING THE NUMBER REMAINING,
*,*               IS NOTED IN THE DCB FOR THE NEXT REFERENCE.
*,*               FOR KEYED DISC FILES, THE NEW FILE POSITION IS FOUND BY
*,*               SCANNING THE INDEX FOR THE FILE.
*,*               IN ANY EVENT, IF ANY ERR OR ABN OCCURS, SUCH AS EOF,
*,*               THE OPERATION IS TERMINATED AT THAT POINT.
         SPACE    2
*D*      NAME:    PRECORD
*,*      INTERFACE TESTOPN, CHKANS0, CHKBIT1, SKREC, T:REG, SETTYC, SETEOPZ,
*,*               MSREXIT, TRUNC, PRDCRD11, GETTYC, SETLKEYUB, READL,
*,*               PRECORDX
*,*      DESCRIPTION IF THE DCB IS NOT OPEN, IT IS OPENNED. IF AN ANS
*,*               TAPE, NO OPERATION IS PERFORMED. FOR DEVICE TAPE, THE
*,*               SPECIFIED NUMBER OF RECORDS IN THE APPROPRIATE DIRECTION
*,*               ARE SKIPPED WITH A SINGLE CALL TO IOQ THAT INCLUDES
*,*               THE NUMBER OF REPEATS. FOR LABEL TAPE, READL IN RDL IS
*,*               CALLED TO PERFORM A READ OR READ REVERSE, AS APPROPRIATE,
*,*               OF ZERO BYTES, THE CALL BEING REPEATED THE NUMBER OF
*,*               TIMES NECESSARY . FOR SEQUENTIAL DISK FILES, THE NUMBER
*,*               OF RECORDS TO SKIP, NOT EXCEEDING THE NUMBER REMAINING,
*,*               IS NOTED IN THE DCB FOR THE NEXT REFERENCE.
*,*               FOR KEYED DISC FILES, THE NEW FILE POSITION IS FOUND BY
*,*               SCANNING THE INDEX FOR THE FILE.
*,*               IN ANY EVENT, IF ANY ERR OR ABN OCCURS, SUCH AS EOF,
*,*               THE OPERATION IS TERMINATED AT THAT POINT.
         BAL,SR1  TESTOPN
         BAL,R0   CHKANS0
         B        MSRWRTX
         LI,D1    K1
         BAL,R2   CHKBIT1
         B        %+1
         BAL,R0   SETPOS
         LI,D2    K1FFFF
         BAL,R2   CHKBIT
         STS,D1   J:JIT+ABO
         BAL,1    JASN
         B        PRECORD2
         BAL,SR4  GETAVR            SET R2 FOR EA
         LW,2     3
         LI,0     0                 INHTIALIZE
         STW,0    AVRSID,R3
         BAL,SR2           SKREC
         BAL,SR4           GETAVR
         DISABLE
PREC1    LI,7     0
         XW,7     AVRSID,R3         GET TYC,RRC
         BNEZ     PRECX
         PUSH     R6
         LI,R6    E:NQW
         BAL,SR4  T:REG
         PULL     R6
         B        PREC1             CHECK IF DONE YET
PRECX    ENABLE
         LB,D1    7                 TYC
         AND,7    M24
         BAL,R0   SETTYC
         B        PRECL4
*                                   DOES USER WANT TO WAIT
PRECORDX EQU      %
         BAL,R0   SETEOPZ
PRECORDX1  EQU    %
         LI,D1    K0
         LW,D2    Y001
         STS,D1   WAT,R6
         DESTRUCT MSREXIT
SETPOS   EQU      %
         STW,D1   NVA,R6
         LW,D1    0,R7              SAVE DIRECTION
         SLS,D1   6
         LI,D2    K400
         STS,D1   DIR,R6
         B        *R0
*
PRECORD2 EQU      %
         CI,D2    K2
         BE       PRECL3
         PAGE
         LI,0     X'20'
         CW,0     ORG,6
         BANZ     SEQ7              KEYED
         LW,0     CDA,6             # TO BE SKIPPED
         LI,2     K400
         CW,2     DIR,6             CHK DIRECTION
         BAZ      %+2               FORWARD
         LCW,0    CDA,6             BACKWARD
         AWM,0    W19,6             SET # TO BE SKIPPED
         LCW,0    W19,6
         SW,0     W14,6             NEW POSN
         BLEZ     SEQ8              OK SO FAR
SEQ2     RES      0                 ERROR AMOUNT
         AWM,0    W19,6             RESET SKIP COUNT
         B        SEQ9              SET TYC & OUT
SEQ8     LW,1     CFU,6
         AW,0     TDA,1             LAST REC #
         BLZ      SEQ2              BAD NEWS
         LI,0     0                 NO MORE TO SKIP
SEQ9     AI,0     0
         BGEZ     %+2
         LCW,0    0                 MAKE IT +
         STW,0    CDA,6
         LI,1     K7FFF
         SLD,0    17
         STS,0    ARS,6
         B        SETBOFEOF
SEQ7     RES      0
         LI,R0    X'8000'           SHARED BIT
         LW,R1    CFU,R6
         CW,R0    0,R1
         BAZ      SEQ71             NOT SHARED
         LI,R0    X'100'            CHK IN
         CW,R0    0,R1
         BANZ     %+2
         LW,R1    SCFU,R1
         LW,D1    COUNTS,R1
COUNTS   EQU      GAVAL
         LW,D2    YFF
         LW,R2    TSTACK
         STS,D1   -2,R2             SAVE IN R10 IN PUSHALL
         LW,D2    M24
         CS,D1    CLK,R6
         BE       SEQ71
         STS,D1   CLK,R6
         BAL,SR4  TRUNC             FRESH BUFFERS
SEQ71    RES      0
         BAL,SR4  PRDCRD11
         LW,D1    CDA,R6            NO REMAINING TO SKIP
         LW,R1    CFU,R6
         BAL,R4   GETTYC
         BNEZ     1A1               EOF OR BOF
         LW,D2    FDA,R1
         BLEZ     1A2
         LI,D1    0                 FOR ARS
         B        1A2
1A1      LI,D2    X'400'
         CW,D2    DIR,R6
         BAZ      1A2
         AI,D1    K1
1A2      RES      0
         LI,D2    K7FFF
         SLD,D1   17
         STS,D1   ARS,R6
         LW,D1    FDA,R1
         BLEZ     SETBOFEOF         SET TYC 4 NULL FILES
*
         CI,R3    K7
*
         BNE      PRECORDX
         BAL,R0   SETLKEYUB         SET UP FOR EOF
         LW,D1    CDA,R6
         BNEZ     PRECORDX
*
SETBOFEOF  EQU    %
         LW,D1    CDA,R6
         BEZ      BOFEOF1
         LI,D1    K7
         LI,R1    K400
         CW,R1    DIR,R6
         BAZ      BOFEOF1           READ FORWARD
         LI,D1    K4
BOFEOF1  EQU      %
         BAL,R0   SETTYC
         B        PRECORDX
         PAGE
PRECL3   EQU      %
*                                   POSITION RECORD ON BLOCKED
*                                   LABELED TAPE
         LI,R0    K0
         STW,R0   RWS,R6
         LW,R1    Y08               RESET ULBL
         STS,R0   ORG,R6
         LW,R1    Y001
         STS,R1   WAT,R6
         LI,SR4   PRECL
         LW,R7    NVA,R6            READ ZERO RECORD LENGTH N TIMES
        BEZ        PRECL4
PRECL1   EQU      %
         LCI      K2                SAVE  ERO,ABO
         LM,R0    J:JIT+ERO
         PSM,R0   TSTACK
         LI,R0    0
         LI,R1    K1FFFF
         STS,R0   KAD,R6
         REMEMBER
         BAL,R1   PUSHALL
         OVERTO   LBLTSEG,0
PRECL    EQU      %
         PULL     1,D3              RESTORE OVERRIDES
         LI,D4    K1FFFF
         STS,D3   J:JIT+ABO
         PULL     1,D3
         STS,D3   J:JIT+ERO
         LB,D3    SR3
         BEZ      PRECL5
         CI,D3    7                 CHK LOST DATA
         BNE      PRECL2
         LI,D1    0
         BAL,R0   SETTYC            RESET LOST DATA
PRECL5   RES      0
         BDR,R7   PRECL1
         B         PRECL4
PRECL2   EQU      %
         BDR,7     %+1
PRECL4   EQU       %
         LW,D3    R7                SET UP ARS
         LI,D4    K7FFF
         SLD,D3   17
         STS,D3   ARS,R6
         LI,D4    K1000
         STS,D3   EGV,R6
         B        PRECORDX
MSRWRTXX EQU      %
         DESTRUCT MSRWRTX
         END

