*M*      HANDLER FOR MPC TAPE DRIVES.
 TITLE '*** M P C  T A P E  D R I V E  H A N D L E R ***'
         PCC      0
         SYSTEM   UTS
*WORD 0-CONTROL OR SENSE ORDER
*     1
* * * * * * * * * * * * * * *
*     2-R/W/TIC/SKIP READ           RDWTIC, RDWT
*     3
* * * * * * * * * * * * * * *
*     4-READ (FOR READ REVERSE)
*     5
* * * * * * * * * * * * * * *
*     6-SENSE ERROR LOG HEADING
*     7
* * * * * * * * * * * * * * *
*     8-SENSE INF0                  DA(SENSEBUF)
*     9
* * * * * * * * * * * * * * *
*     10-IDCW                       DA(IDCW)
*     11
* * * * * * * * * * * * * * *
*     12-C.F.C.,,# BYTES CURR REC.  BYTESKIP,ERASESAV,REWRTSAV,
*                                   SENSAVE,REWSAV
*     13-# ERASURES,# BYTES LAST G.
* * * * * * * * * * * * * * *
*     14-TDV DOUBLE WORD            DCT13SAV
*     15
* * * * * * * * * * * * * * *
*     16- NZ=EOT CROSSED            EOTSAV, CORRDSAV
*     17- NZ=CORRECTABLE RD ERR
* * * * * * * * * * * * * * *
         PAGE
MPCTIO:  EQU      %                 PATCHING SYMBOL FOR XDELTA
MPCT     EQU      %
*
         DEF      MPCTIO:,MPCTIO,MPCTCU
*
         REF      DCT3
         REF      DCT1P,DCT7,DCT12,DCT13,DCT17,DCT19
         REF      IOQ4,IOQ5,IOQ8,IOQ9,IOQ10,IOQ11,IOQ12
         REF      YFF,Y02,Y08,Y8,Y4,Y2,YC
         REF      M16,M24,M6,M4,NBYT2,M3
         REF      MSG2,MSG5,MSG9A
         REF      COMLIST,USECOM
         REF      IOSST,IOSCU,IOARS
         REF      RE:ENT,RECIOERR,IOSERCK
         REF      ERRLOG,DOUBLEZERO
         PAGE
*
*        REGISTER DEFINITIONS
*
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
         PAGE
RDWT     EQU      2                 DW  READ/WRITE CDW
RDWTIC   EQU      2                 DW  RD/WT/TIC CDW
SENSEBUF EQU      4                 DA(SENSE BUFFER)
REWRTSAV EQU      12                DW SAVE REWRITE INFO
ERASESAV EQU      12                DW ERASE INFO SAVE
BYTESKIP EQU      12                DW BYTE COUNT INFO
SENSAVE  EQU      12                LAST FUNCTION CODE INFO
REWSAV   EQU      12                REWIND INFO SAVE AREA
DCT13SAV EQU      14                DW TDV STATUS SAVE
CORRDSAV EQU      16                DW CORRECTABLE READ ERROR FLAG
EOTSAV   EQU      16                DW END OF TAPE FLAG
IDCW     EQU      5                 DA(IDCW)
*
TYCTM    EQU      6                 TAPE MARK TYPE COMPLETE CODE
TYCEOD   EQU      6                 END OF DATA
TYCEOT   EQU      5                 END OF TAPE
TYCLDAT  EQU      2                 LOST DATA
TYCBOT   EQU      3                 BEGINNING OF TAPE
TYCOK    EQU      1                 DATA TRANSFER
TYCERR   EQU      8                 ERROR
TYCEREOT EQU      X'13'             ERROR AFTER EOT
         PAGE
NOISE    EQU      %                 READ ERROR COMES HERE
         LD,R8    DCT13SAV,R5       TDV FROM READ
         STD,R8   DCT13,R1          PUT BACK FOR CALLER
         BAL,R13  IOARS             GET RECORD SIZE
         CI,R11   0                 ANY REMIANING BYTES
         BEZ      FOLLOWON          NO-CAN'T BE NOISE RECORD
         CI,R8    12                12 OR MORE BYTES NOT NOISE
         BGE      FOLLOWON          RETRY
         LB,R5    IOQ4,R3           CALLING FUNCTION CODE
         STH,R5   DCT17,R1          MAKE FOLOWON CODE
         B        FOLLOWON          ASSUME NOISE AND READ NEXT RECORD
*
SPAC:REC EQU      %                 COME HERE AFTER EXTERNAL SPACE COMMAND
         CLM,R12  BOT%EOT%TM
         BIL      SPC:TST           HIT BOT OR TM RETURN TO CALLER
         MTW,-1   IOQ12,R3          DEC PRECORD COUNTER
         BGZ      FOLLOWON          MOVE ANOTHER RECORD
SPC:TST  LD,R10   DCT13,R1          TDV FROM SPACE COMMAND
         LW,R11   IOQ12,R3          GET NUMBER OF RECORDS REMAINING
         STD,R10  DCT13,R1          REPLACE AS RBC FIELD
         SLS,R11  1                 DOUBLE RBC
         STH,R11  IOQ9,R3           SET UP SO THAT IOARS WILL WORK
         B        EXITOK            BACK TO CALLER
*
SPAC:FIL EQU      %                 SPACE FILE COMES HERE
         CLM,R12  BOT%EOT%TM        CROSS TM OR AT BOT
         BIL      EXITOK1           YES DONE
         B        RETRY             NO-RETRY SPACE FILE AGAIN
*
MODECNTL EQU      %                 MODE CONTROL COMES HERE
         LI,R12   0                 NO XFER TYC
         LB,R5    IOQ4,R3           CALLING FUNCTION CODE
         CI,R5    FCMC              CALLER CALLED
         BE       EXITOK1           YES-GO BACK
         STH,R5   DCT17,R1          NO-RETRY THE ORIGONAL F. C.
         B        FOLLOWON
*
SKIPRERR EQU      %                 SKIP READ ERROR PATH
         LD,R10   DCT13SAV,R5       TDV STATUS FROM ERROR
         STD,R10  DCT13,R1            BACK TO DCT13
SKIPREAD EQU      %                 COME HERE AFTER SKIP READ
         CI,R12   TYCTM             JUST READ A TM
         BE       FOLLOWON          YES-NOTHING TO DO
         LD,R10   DCT13,R1          TDV FROM THE SKIP READ
         AND,R11  M16               RBC
         LI,R10   X'10000'          STARTING BYTE COUNT
         SW,R10   R11               ARS
         AND,R10  M16
         LD,R6    BYTESKIP,R5       SKIPREAD SAVE AREA
         CI,R7    X'FFFF'           ANY B. C. THERE NOW
         BAZ      SKIPRD1           NO
         INT,R7   R7                ISOLATE PREVIOU COUNT
         CW,R10   R7                COUNT STILL THE SAME
         BE       FOLLOWON          YES-KEEP GOING
LOSTPOS  EQU      %
         LB,R6    DCT3,R1           IF TIMEOUT OCCURRED WITH TAPE MOTION,
         AND,R6   =X'EF'               WE RESET THE DEV TIMEOUT INDICATOR
         STB,R6   DCT3,R1            & REPORT IT AS 'LOST POSITION'
         LI,R6    0
         STB,R6   IOQ11,R3          NO MORE RETRIES
         LI,R13   LOSTMES           'LOST POSITION' MESSAGE
         B        RETRYC            BACK TO CALLER
LOSTMES  TEXTC    ' ERROR-TAPE LOST POSITION'
SKIPRD1  OR,R7    R10               PUT ARS
         STD,R6   BYTESKIP,R5       SAVE BYTE COUNT
         B        FOLLOWON          NEXT STEP
*
SAVDCT13 EQU      %                 COME HERE TO SAVE TDV STATUS IN CLIST
         LD,R8    DCT13,R1          TDV STATUS
         STD,R8   DCT13SAV,R5       SAVE DCT13 IN CLIST
         B        FOLLOWON
*
RSTDCT13 EQU      %                 RESTORE DCT13 FOR CALLER
         LD,R10   DCT13SAV,R5       TDV STATUS FROM CLIST
         STD,R10  DCT13,R1          RESTORE FOR CALLER
         B        EXITOK
*
SENSDONE EQU      %                 COME HERE AFTER SENSE
         LH,R6    DCT7,R1           DA(CLIST)
         AI,R6    SENSEBUF-1        POINT TO SENSE BUF HEADER
         LW,R8    DCT12,R1          AIO TO GET DEVICE ADDRESS
         AND,R8   M16               DEVICE ADDRESS
         OR,R8    =X'16060000'      SENSE HEADER-INCLUDE THE IDCW
         LI,R9    0                 TIME FIELD
         STD,R8   0,R6              PUT SENSE HEADER IN CLIST
         SLS,R6   1                 MAKE WORD ADDRESS
         BAL,R5   ERRLOG            MAKE SECONDARY ERROR LOG ENTRY
         LH,R5    DCT7,R1           DA(CLIST)
         LD,R10   SENSAVE,R5        LAST FUNCTION CODE INFO
         LB,R6    R10               LAST F. C.
         LW,R7    DOT,R6            DOT ENTRY FOR LAST FUNCTION
         STH,R7   DCT17,R1          SET BACK UP RETRY-FOL
         LB,R6    IOQ5,R3           CURRENT FUNCTION CODE
         AI,R6    -SENSEVEC         MAKE INDEX TO TYPE OF SENSE
         LB,R6    SVEC,R6           GET ROUTINE DISPLACEMENT
         B        MPCT,R6           GO TO ROUTINE
*
EVECTOR  EQU      %                 COME HERE TO TAKE ERROR VEC.
         LD,R10   SENSAVE,R5
         LB,R6    R10               LAST FUNCTION CODE
         LB,R7    EVEC,R6           DISPLACEMENT TO ERROR ROUTINE
         B        MPCT,R7           GO TO ERORR ROUTINE
*
SRTY     EQU      %                 SENSE THEN RETRY
         LD,R10   SENSAVE,R5        SENSE INFO FROM CLIST
         LB,R6    R10               LAST FUNCTION CODE
         LW,R7    DOT,R6            DOT ENTRY FOR LAST F. C.
         SLS,R7   -8                POSITION RETRY F. C.
         STH,R7   DCT17,R1          MAKE RETRY CODE FOLLOWON CODE
         B        FOLLOWON
*
EXITOK   EQU      %
         CLM,R12  TYC:RAN           LEGAL TYC RANGE
         BIL      IOSCU             YES-BACK TO CALLER
         LI,R12   TYCOK             SET OK DATA XFER
EXITOK1  EQU      %                 TYC ALREADY SET
         B        IOSCU             BACK TO IOQ
*
FOLLOWON EQU      %
         LI,R12   X'6000'           FOLLOW ON CODE
         B        IOSCU             BACK TO IOQ
*
*
OPER     EQU      %                 OPERATOR INTERVENTION REQUIRED
         BAL,R5   RECOORD           MAKE PRIMARY ERROR LOG ENTRY
OPERA    LI,R12   X'2800'           KEYIN CODE
         LI,R13   MSG2              'ERROR'          MESSAGE
         B        IOSCU             BACK TO IOQ
*
*
*
*        RECORD ERROR LOG ENTRY
*
RECOORD  EQU      %
         LI,R6    X'150D'           ERROR MSG CODE AND COUNT
         B        RECIOERR          MERGE
STOP     EQU      %
         LI,R6    0
         STB,R6   IOQ11,R3          NO MORE RETRIES
         LI,R13   MSG9A             'INCONSISTENT STATUS'
         B        RETRYC            REPORT ERROR TO CALLER
ERASECNT EQU      %                 COME HERE TO COMPUTE NO. OF ERASES.
         CI,R12   TYCBOT            AT BOT
         BE       BOT1              YES-HAVE OPERATOR STRIP THE TAPE
         BAL,R13  IOARS             GET ARS OF CURRENT RECORD
         LW,R9    R8                SAVE ARS
         LI,R5    2800              BYTES/3.5 IN. OF TAPE
         DW,R9    R5
         AI,R9    2                 NUMBER OF ERASES TO DO
         LB,R5    IOQ10,R3          STARTING RETRY COUNT
         LB,R6    IOQ11,R3          CURRENT RETRY COUNT
         SW,R5    R6                NUMBER OF TIMES HERE
         MW,R9    R5                GET TOTAL NUMBER OF ERASES
         LH,R5    DCT7,R1           DA(CLIST)
         LD,R10   ERASESAV,R5       SAVE AREA IN CLIST
         STW,R8   R10               ARS OF CURRENT WRITE
         STH,R9   R11               ERASE COUNT
         STD,R10  ERASESAV,R5       SAVE INFO IN CLIST
         LD,R10   EOTSAV,R5
         MTW,0    R10               AT END OF TAPE
         BEZ      FOLLOWON          NO
         LI,R10   0                 YES-SET RETRY COUNT TO ZERO
         STB,R10  IOQ11,R3
         B        FOLLOWON
*
ERSE     EQU      %                 COME HERE AFTER ERASE F. C.
         LD,R10   ERASESAV,R5       ERASE INFO
         MTH,-1   R11               DEC. ERASE COUNT
         STD,R10  ERASESAV,R5       PUT INFO BACK TO CLIST
         BLEZ     FOLLOWON          DONE ERASEING NEXT STEP
         LH,R7    DCT17,R1
         SLS,R7   -8
         STH,R7   DCT17,R1          MAKE RETRY CODE FOLLOWON CODE
         B        FOLLOWON
*
CHECKCNT EQU      %                 COME HERE AFTER SKIP READ OF REWRITE
         LD,R8    DCT13,R1          TDV STATUS
         AND,R9   M16               RBC
         LI,R8    X'10000'          INITIAL BYTE COUNT
         SW,R8    R9
         AND,R8   M16               ARS OF RECORD ON TAPE
         LD,R10   REWRTSAV,R5       RE-WRITE INFO
         AND,R10  M16               ARS FROM BUFFER
         CW,R8    R10               RECORD ON TAPE CORRECT SIZE
         BNE      CHECKC1           NO-TRY AGAIN
         LD,R10   DOUBLEZERO
         STD,R10  REWRTSAV,R5       YES-CLEAR RE-WRITE INFO
         LD,R10   EOTSAV,R5         END OF TAPE INFO
         MTW,0    R10               CROSS EOT DURING THIS RETRY
         BEZ      RSTDCT13          NO-RESTORE TDV FOR CALLER
         LI,R12   TYCEOT            YES-GIVE CALLER EOT TYC
         B        RSTDCT13
CHECKC1  MTB,0    IOQ11,R3          ANY RETRIES REMAINING
         BNEZ     RETRY             YES-KEEP TRYING
         LI,R13   WFAILMES          'WRITE RECOVERY FAILURE'
         B        RETRYC            BACK TO CALLER
WFAILMES TEXTC    ' WRITE RECOVERY FAILURE'
*
REWRTERR EQU      %                 COME HERE IF RE-WRITE FAILED
         LI,R5    FCWT1             START AGAIN AT THE CORRECTION F.C.
         STH,R5   DCT17,R1          MAKE FOLLOW ON CODE
         B        FOLLOWON
*
READBERR EQU      %                 COME HERE ON READ BACKWARD RETRY ERR
         LI,R5    FCRDB1            START AGAIN AT CORRECTION FC
         STH,R5   DCT17,R1          MAKE FOLLOW ON CODE
         B        FOLLOWON
*
READBERA EQU      %                 COME HERE TO CHECK RD REV
         MTB,0    IOQ11,R3          ANY RETRIES REMAINING
         BNEZ     FOLLOWON          YES-RE-READ THE RECORD
         LI,R13   MSG2              NO-KEEP TAPE AT FROUNT OF RECORD
         B        RETRYC
*
READREV  EQU      %                 COME HERE ON READ REVERSE
         CLM,R12  BOT%EOT%TM        HIT BOT OR TM
         BIL      EXITOK1           YES-TELL CALLER
         B        FOLLOWON          NO-CONTINUE TO SIMULATE READ REV
*
READREVB EQU      %                 COME HERE AT END OF READ REV SIMULATION
         LD,R10   DCT13SAV,R5       REAL TDV DOUBLE WORD
         STD,R10  DCT13,R1          INTO DCT13 FOR IOARS
         BAL,R13  IOARS             GET ARS FORM CLIST/MPOOL
         LH,R5    DCT7,R1           DA(CLIST)
         LD,R10   BYTESKIP,R5       ARS INFO
         AND,R11  M16               ARS FROM TAPE
         CW,R11   R8                C/WITH ARS FROM BUFFER- LOST DATA
         BLE      %+2               NO
         LI,R12   TYCLDAT           YES-SO INDICATE
         LD,R10   DOUBLEZERO
         STD,R10  BYTESKIP,R5       CLEAN READ REV INFO IN CLIST
         B        EXITOK            DONE-BACK TO CALLER
*
READREVA EQU      %                 SET UP READ REVERSE
         LD,R10   BYTESKIP,R5       ARS INFO
         AND,R11  M16               ARS OF RECORD ON TAPE
         LW,R4    IOQ8,R3           BUFFER ADDRESS
         BLZ      READREV2          DATA CHAINED
         AND,R4   M24               STRIP FLAGS
         LH,R7    IOQ9,R3           BUFFER SIZE
         AND,R7   M16
         LD,R8    RDF               READ CDW
         AND,R9   NBYT2             CLEAN CDW
         CH,R11   IOQ9,R3           C/ARS ON TAPE WITH BUFFER SIZE
         BG       READREV1          GOING TO HAVE LOST DATA
         AW,R4    R7
         SW,R4    R11               AJUSTED BUFFER ADDRESS
         OR,R8    R4                ADJUSTED BUFFER ADDRESS
         OR,R9    R11               ARS IS BYTE COUNT
         STD,R8   RDWT,R5           PUT READ INTO CLIST
         B        FOLLOWON
*                                   LOST DATA- NO DATA CHAIN
READREV1 SH,R11   IOQ9,R3
         AND,R11  M16               LOST DATA PORTION
         LI,R6    (DC+SKIP)**8+X'80' CDW FLAGS
         STH,R6   R11                 INTO SECOBD WORD OF CDW
         LW,R10   Y02               READ ORDER
         STD,R10  RDWT,R5           SKIP CDW INTO CLIST
         OR,R8    R4                BUFFER ADDRESS
         OR,R9    R7                BUFFER SIZE
         STD,R8   RDWT+2,R5         CDW INTO CLIST
         B        FOLLOWON
READREV2 EQU      %                 DATA CHAINED READ BACKWARD
         AND,R4   M24               DA(MPOOL)
         LI,R5    1
         LH,R13   IOQ9,R3           # OF CDWS IN MPOOL
         LI,R0    DC**8+X'80'       CDW FLAGS
         LI,R15   2                 READ ORDER
         AH,R4    IOQ9,R3           NEXT AVIALABLE DOUBLE WORD IN MPOOL
         LW,R6    R4                IN R6
         AI,R4    -1                LAST CDW IN MPOOL
         CI,R13   17                MPOOL FULL
         BL       %+2               NO
         LW,R6    R4                YES-CANT MOVE DOWN FOR SKIP READ
         LW,R7    R6                POSITION OF LAST CDW IN MPOOL
         LI,R10   0                 BYTE COUNTER
READREV3 LD,R8    0,R4              LAST CDW
         STB,R15  R8                READ ORDER
         STH,R0   R9                CDW FLAGS
         AH,R10   R9,R5             ADD UP THE BYTES
         STD,R8   0,R6              MOVE CDWS DOWN ONE DOUBLE WORD
         CW,R10   R11               C/ BYTE COUNT WITH ARS ON TAPE
         BE       READREV5          BUFFER AT THIS POINT = ARS
         BG       READREV4          BUFFER LARGER THAN ARS
         AI,R4    -1
         AI,R6    -1                POINT BACK UP THE MPOOL
         BDR,R13  READREV3          GO THROUGH THE CDWS
*                                   LOST DATA- DATA CHAINED
         LH,R13   IOQ9,R3           NUMBER OF CDWS IN MPOOL
         CI,R13   17                MPOOL FULL
         BL       %+3               NO
         AI,R4    1                 YES-THE TIC POINTS TO 1ST WORD OF MPOOL
         B        READREV7
         LW,R9    R11               ARS ON TAPE
         SW,R9    R10               LOST DATA PORTION
         LI,R0    (DC+SKIP)**8+X'80' CDW FLAGS
         STH,R0   R9                INTO CDW
         LW,R8    Y02               READ ORDER
         STD,R8   0,R6              SKIP READ INTO MPOOL
         LW,R4    R6                TIC POINTS HERE
         B        READREV6
*                                   BUFFER LARGER THAN ARS
READREV4 LW,R5    R10               BUFFER SIZE
         SW,R5    R11               EXCESS IN BUFFER
         AW,R8    R5                ADJUST BUFFER ADDRESS DOWN
         SW,R9    R5                ADJUST BYTE COUNT
         STD,R8   0,R6              BACK INTO MPOOL
*                                   BUFFER = ARS
READREV5 LW,R4    R6                TIC POINTS HERE
         LD,R8    DOUBLEZERO
         AI,R6    -1                POINT BACK UP THE MPOOL
         STD,R8   0,R6              ZERO CDW SO IOARS WILL WORK
         BDR,R13  %-2               CLEAN OUT THE MPOOL
READREV6 MTH,1    IOQ9,R3           COUNT THE SKIP READ CDW
READREV7 LH,R5    DCT7,R1           DA(CLIST)
         LW,R8    Y08               TIC ORDER CODE
         LI,R9    0
         OR,R8    R4                DA(FIRST CDW IN MPOOL)
         STD,R8   RDWTIC,R5         PUT TIC IN CLIST
         LD,R8    0,R7              LAST CDW IN MPOOL
         LI,R0    X'1E80'           LAST CDW FLAGS
         STH,R0   R9
         STD,R8   0,R7              BACK TO MPOOL
         B        FOLLOWON
         PAGE
:GNVCT   COM,8    AF-ERR
*
MAJ:STAT EQU      %                 MAJOR STATUS VECTOR
         DATA,1   0                 (READY)
         :GNVCT   DEVBUSY           1 - DEVICE BUSY
         :GNVCT   DEVATTN           2 - DEVICE ATTENTION
         :GNVCT   DEVDALRT          3 - DEVICE DATA ALERT
         :GNVCT   ENDOFILE          4 - END OF FILE
         :GNVCT   CMDREJ            5 - COMMAND REJECT
         :GNVCT   ERR               6
         :GNVCT   ERR               7
         :GNVCT   ERR               8
         :GNVCT   ERR               9
         :GNVCT   MDEVATTN          A - MPC DEVICE ATTENTION
         :GNVCT   MDEVDLRT          B - MPC DEVICE DATA ALERT
         :GNVCT   ERR               C
         :GNVCT   MPCMDREJ          D - MPC COMMAND REJECT
         :GNVCT   ERR               E
         :GNVCT   ERR               F
         BOUND    4
         PAGE
         LOCAL    ERRRET,OPER,RETRY,WPROTECT,BLANKTAP,EOT,EOF,USERERR,;
                  BOT,DENSITY,MBOT,CORRERR
*
ERRRRET,ERRRET  EQU  0
OPER     EQU      1
RETRY    EQU      2
WPROTECT EQU      3
BLANKTAP EQU      4
EOT      EQU      5
EOF      EQU      6
USERERR  EQU      7
BOT      EQU      8
DENSITY  EQU      9
MBOT     EQU      10
CORRERR  EQU      11
         PAGE
:GENDAT  CNAME
         PROC
         LIST     0
         DO       AF(1)>0
         DO       AF(1)-P%-1
         DATA,1   ERRRRET
         FIN
         ELSE
         FIN
         LIST     1
         DATA,1   AF(2)
P%       SET      AF(1)
         PEND
*
         PAGE
ERR      EQU      %-1
DEVBUSY  EQU      %                 0001  DEVICE BUSY
         :GENDAT  0,ERRRET          FILL OUT
         :GENDAT  1,OPER            IN REWIND
         :GENDAT  2,RETRY           ALTERNATE CHANNEL IN CONTROL
         :GENDAT  4,OPER            DEVICE LOADING
         :GENDAT  X'20',RETRY       DEVICE RESERVED
         :GENDAT  X'3F',ERRRET      FILL OUT
DEVATTN  EQU      %                 0010  DEVICE ATTENTION
         :GENDAT  0,ERRRET          FILL OUT
         :GENDAT  1,WPROTECT        WRITE PROTECTED
         :GENDAT  2,OPER            NO SUCH DRIVE
         :GENDAT  4,OPER            DRIVE IN STANBY
         :GENDAT  5,WPROTECT
         :GENDAT  8,OPER            DRIVE CHECK(DEVICE FAULT)
         :GENDAT  9,WPROTECT
         :GENDAT  X'C',OPER
         :GENDAT  X'D',WPROTECT
         :GENDAT  X'10',ERRRET      BLANK TAPE ON WRITE
         :GENDAT  X'14',ERRRET
         :GENDAT  X'15',OPER
         :GENDAT  X'18',ERRRET
         :GENDAT  X'19',OPER
         :GENDAT  X'1C',ERRRET
         :GENDAT  X'1D',OPER
         :GENDAT  X'3F',ERRRET      FILL OUT
DEVDALRT EQU      %                 0011  DEVICE DATA ALERT
         :GENDAT  0,ERRRET          FILL OUT
         :GENDAT  1,RETRY           TRANSFER TIMING ALERT
         :GENDAT  2,BLANKTAP        BLANK TAPE ON READ
         :GENDAT  3,ERRRET          BIT DETECTED DURING ERASE
         :GENDAT  4,RETRY           TRANSMISSION PARITY ALERT(DROP OUT)
         :GENDAT  7,ERRRET          BIT DETECTED DURING ERASE
         :GENDAT  8,RETRY           LATERAL PARITY ALERT
         :GENDAT  X'B',ERRRET       BIT DETECTED DURING ERASE
         :GENDAT  X'C',RETRY
         :GENDAT  X'F',ERRRET       BIT DETECTED DURING ERASE
         :GENDAT  X'10',RETRY       LONGITUDINAL PARITY ALERT
         :GENDAT  X'13',ERRRET      BIT DETECTED DURING ERASE
         :GENDAT  X'14',RETRY
         :GENDAT  X'17',ERRRET      BIT DETECTED DURING ERASE
         :GENDAT  X'18',RETRY
         :GENDAT  X'1B',ERRRET      BIT DETECTED DURING ERASE
         :GENDAT  X'1C',RETRY
         :GENDAT  X'1F',ERRRET      BIT DETECTED DURING ERASE
I        DO       X'1F'
         :GENDAT  X'1F'+I,EOT       END OF TAPE
         FIN
         :GENDAT  X'3F',ERRRET      INCOMPATIBLE CHAR.
ENDOFILE EQU      %                 0100  END OF FILE
I        DO       X'40'
         :GENDAT  I-1,EOF           END OF FILE
         FIN
CMDREJ   EQU      %                 0101  COMMAND REJECT
         :GENDAT  0,USERERR         INVALID DENSITY
         :GENDAT  1,RETRY           INVALID OPERATION CODE
         :GENDAT  2,RETRY           INVALID DEVICE CODE
         :GENDAT  3,RETRY
         :GENDAT  4,RETRY           INVALID IDCW PARITY
         :GENDAT  5,RETRY
         :GENDAT  6,RETRY
         :GENDAT  7,RETRY
         :GENDAT  8,BOT             UNEXPECTED BOT
         :GENDAT  X'10',USERERR     FORWARD READ AFTER WRITE
         :GENDAT  X'20',RETRY       NINE TRACK ERROR
         :GENDAT  X'3F',ERRRET      FILL OUT
MDEVATTN EQU      %                 1010  MPC DEVICE ATTENTION
         :GENDAT  0,ERRRET          FILL OUT
         :GENDAT  1,OPER            CONFIGURATION SWITCH ERROR
         :GENDAT  2,OPER            MULTIPLE DEVICES
         :GENDAT  3,OPER            ILLEGAL DEVICE ID NUMBER
         :GENDAT  8,DENSITY         INCOMPATIBLE MODE
         :GENDAT  X'C',OPER         TCA MALFUNCTION
         :GENDAT  X'D',OPER
         :GENDAT  X'E',OPER
         :GENDAT  X'F',OPER
         :GENDAT  X'10',OPER        MTH MALFUNCTION
         :GENDAT  X'11',MBOT        MULTIPLE BOT
         :GENDAT  X'3F',ERRRET      FILL OUT
MDEVDLRT EQU      %                 1011  MPC DEVICE DATA ALERT
         :GENDAT  0,ERRRET          FILL OUT
         :GENDAT  1,RETRY           TRANSMISSION PARITY ALERT
         :GENDAT  2,RETRY           INCONSISTANT COMMAND
         :GENDAT  3,RETRY           SUM CHECK ERROR
         :GENDAT  4,RETRY           BYTE LOCKED OUT
         :GENDAT  8,RETRY           PE-BURST WRITE ERROR
         :GENDAT  9,RETRY           PREAMBLE ERROR
         :GENDAT  X'10',RETRY       MULTI-TRACK ERROR
         :GENDAT  X'11',RETRY       SKEW ERROR
         :GENDAT  X'12',RETRY       POSTAMBLE ERROR
         :GENDAT  X'13',CORRERR     NRZI CCC ERROR(CORRECTABLE)
         :GENDAT  X'14',RETRY       CODE ALERT
         :GENDAT  X'20',RETRY       MARGINAL CONDITION
         :GENDAT  X'3F',ERRRET      FILL OUT
MPCMDREJ EQU      %                 1101  MPC COMMAND REJECT
         :GENDAT  0,ERRRET          FILL OUT
         :GENDAT  1,RETRY           ILLEGAL PROCEDURE
         :GENDAT  2,RETRY           ILLEGAL LC NUMBER
         :GENDAT  3,RETRY           ILLEGAL SUSPENDED LC NUMBER
         :GENDAT  4,RETRY           CONTINUE BIT NOT SET
         :GENDAT  X'3F',ERRRET      FILL OUT
         LOCAL
         PAGE
ACTIONS  B        ERRRET            ERROR LOG AND STOP
         B        OPER              KEYIN REQUIRED
         B        RETRY             RETRY SEQUENCE
         B        WPROTECT          TAPE IS WRITE PROTECTED
         B        BLANKTAP          25' OF BLANK TAPE READ
         B        EOT               EOT REFLECTOR CROSSED
         B        EOF               TM READ
         B        USERERR           BAD SEQUENCE BY CALLER
         B        BOT               UNEXPECTED BOT HIT
         B        DENSITY           CANT READ BECAUSE OF BAD DENSITY
         B        MBOT              MULTIPLE BOT REFLECTORS ON TAPE
         B        CORRERR           CORRECTABLE READ ERROR ON TAPE
         PAGE
         BOUND    8
BOT%EOT%TM  DATA  3,6               TAPE MARK TYC RANGE
DESEN    DATA     X'11',X'14'       RANGE OF SENSE FUNCTION CODES
RFCODE   DATA     8,X'B'            RANGE OF REWIND FUNCTION CODES
TYC:RAN  DATA     1,X'15'           RANGE OF LEGAL TYCS
MPCTCU   EQU      %                 MPC TAPE CLEAN UP ENTRY POINT
         BAL,R9   IOSERCK           CHECK FOR GENERAL ERRORS
         B        TMOUTCHK          ERROR FOUND- ERROR LOG ENTRY MADE
*                                   TIMEOUTS ALSO RET ALONG ERROR PATH
         LW,R5    DCT12,R1          AIO STATUS
         BLZ      REWIND            DEVICE INTERRUPT HAS OCCURED
*
         LB,R6    R5                DEVICE STATUS BYTE FROM AIO
         AND,R6   M6                MPC SUB STATUS FIELD
         LD,R8    DCT13,R1          TDV STATUS
         LB,R7    R9                DEVICE STATUS BYTE
         AND,R7   =X'6F'            REMOVE INIT INTERRUPT AND STRAY BIT
         AI,R7    -X'20'            CHECK OPI SET
         BEZ      READY             OPI SET AND MAJOR STATUS ZERO
*
         CI,R7    X'E0'
         BANZ     MPCTCU1           TDV0-2, NOT 001
         AND,R7   M4                MPC MAJOR STATUS
         LB,R5    MAJ:STAT,R7       GET MAJOR STATUS VECTOR
         BEZ      ERRRET            NO SUCH MAJOR STATUS
         AI,R5    ERR               POINT TO MINOR STATUS VECTOR
         LB,R4    *R5,R6            MINOR STATUS VECTOR
         LH,R5    DCT7,R1           DA(CLIST)
         EXU      ACTIONS,R4        AND GO.
*
MPCTCU1  AI,R7    X'20'             PUT TDV0-2 BACK
         BNEZ     RETRY             TDV0-2 NOT 000
*
         LB,R10   IOQ5,R3           CURRENT FUNCTION CODE
         CLM,R10  DESEN             INTERNAL SENSE FUNCTION CODE
         BIL      NORMAL            YES-OK
         B        OPER              DONT KNOW WHAT IT IS
*
*
READY    EQU      %                 MAJOR STATUS IS ZERO(READY)
         CI,R6    2                 AT BOT
         BAZ      %+2               NO
         LI,R12   TYCBOT            YES-SET BOT TYC
*
NORMAL   EQU      %
         LC       DCT19,R1          AIO CC
         BCS,4    RETRY             UN-END SET
*
         LH,R5    DCT7,R1           DA(CLIST)
NORMALA  LB,R6    IOQ5,R3           CURRENT FUNCTION CODE
         LB,R4    NVEC,R6           NORMAL VECTOR
         B        MPCT,R4           GO TO NORMAL COMPLETION ROUTINE.
*
         PAGE
TMOUTCHK LC       DCT3,R1           WAS IT DEV TIME OUT?
         BCR,1    RETRYA            NO.
         LD,R8    DCT13,R1          Y, DID TAPE MOVE?
         LC       R9                   (I.E., IS INIT BIT OFF?)
         BCS,8    IOSCU             N, REPORT TIMEOUT TO OPERATOR
         B        LOSTPOS           Y, RESET DEV TIMEOUT FLAG
*                                    & ABORT ('LOST POSITION')
CORRERR  EQU      %                 A CORRECTABLE READ ERROR HAS OCURRED
         LD,R8    CORRDSAV,R5       INFO BUFFER IN CLIST
         MTW,1    R9                SET FLAG INDICATING CORRECTABLE RD
         STD,R8   CORRDSAV,R5       SAVE IN CLIST
*
RETRY    EQU      %
         BAL,R5   RECOORD           MAKE PRIMARY ERROR LOG ENTRY
RETRYA   LD,R8    DCT13,R1          TDV STATUS
         LI,R5    SENSEVEC**8       ASSUME TAPE MOVEMENT USE ERROR VEC
         LC       R9                MPC STATUS
         BCR,8    %+2               TAPE DID MOVE
         LI,R5    SENSERTY**8       NO TAPE MOVEMENT USE RETRY FC
RETRYB   STH,R5   DCT17,R1          SET RETRY FC
         LH,R5    DCT7,R1           DA(CLIST) BUFFER
         STD,R8   DCT13SAV,R5       SAVE IN CLIST
         LD,R8    SENSAVE,R5
         LB,R6    IOQ5,R3           CURRENT FUNCTION CODE
         STB,R6   R8
         STD,R8   SENSAVE,R5        SAVE CFC IN CLIST FOR AFTER SENSE
         LI,R13   MSG2              'ERROR' MESSAGE
RETRYC   LI,R12   X'A4'**8+TYCERR   RETRY CODE
         MTB,0    IOQ11,R3          ANY RETRIES REMAINING
         BNEZ     IOSCU             YES-KEEP GOING
         LD,R8    DOUBLEZERO
         STD,R8   BYTESKIP,R5       CLEAR THE CLIST INFO AREA
         LD,R8    EOTSAV,R5
         MTW,0    R8                END OF TAPE INDICATOR CROSSED
         BEZ      IOSCU             NO-GO WITH PLAIN ERROR CODE
         LI,R12   X'A4'**8+TYCEREOT YES-SET ERROR AFTER EOT
         B        IOSCU             BACK TO IOQ
*
*
ERRRET   EQU      %
         BAL,R5   RECOORD           MAKE PRIMARY ERROR LOG ENTRY
         LI,R5    SENSERR**8        SENSE THEN STOP
         B        RETRYB
*
USERERR  EQU      %                 CALLER HAS GOOFED
         LI,R12   TYCERR            ERROR TYC
         B        IOSCU             BACK TO IOQ
*
BOT      EQU      %                 UNEXPECTED BOT
         LB,R5    IOQ5,R3           CURRENT FUNCTION STEP
         CI,R5    FCWT2             ERROR IN FIRST RECORD ON TAPE
         BE       BOT1              YES-GET OPERATOR INVALED
         LI,R12   TYCBOT            NO-CALLER GOOFED
         B        EXITOK1           REPORT BACK
BOT1     LB,R5    IOQ4,R3           CALLING FUNCTION CODE
         STB,R5   IOQ5,R3           BACK TO ORIG. FUNCTION CODE.
         LI,R12   X'2800'           KEYIN REQUIRED
         LI,R13   STRIPMES          'STRIP TAPE' MESSAGE
         B        IOSCU             BACK TO IOQ
STRIPMES TEXTC    ' STRIP TAPE AND RE-TRY'
*
EOF      EQU      %
         LI,R12   TYCEOD            TAPE MARK HAS BEEN CROSSED
         B        NORMALA
*
BLANKTAP EQU      %                 25 FEET OF BLANK TAPE READ
         LI,R12   X'2800'           KEY IN REQUIRED
         LI,R13   BLANKMES
         B        IOSCU
BLANKMES TEXTC    ' 25 FT. BLANK TAPE READ.'
*
EOT      EQU      %                 END OF TAPE MARKER CROSSED
         LD,R8    EOTSAV,R5
         LI,R8    1                 NO
         STD,R8   EOTSAV,R5         SAVE EOT INDICATOR
         LI,R12   TYCEOT            END OF TAPE TYC
         CI,R6    X'1F'             ANY ERRORS
         BAZ      NORMALA           NO
         CI,R6    3                 YES-BIT DETECTED DURING ERASE
         BAZ      RETRY             NO-RETRY
         B        ERRRET            YES-LOG AND STOP
*
WPROTECT EQU      %                 WRITE RING IS OUT
         LI,R12   X'2800'           KEY IN REQUIRED
         LI,R13   MSG5              'WRITE PROTECTED'
         B        IOSCU             BACK TO IOQ
*
MBOT     EQU      %                 MULTIPLE BOT MARKERS CROSSED
         LI,R12   X'2800'           KEY-IN REQUIRED
         LI,R13   MBOTMES
         B        IOSCU             BACK TO IOQ
MBOTMES  TEXTC    ' MULTIPLE BOT MARKERS'
*
DENSITY  EQU      %                 DRIVE IS AT WRONG DENSITY FOR READ
         LI,R5    FCDENREW          REWIND THE TAPE AND CHANGE DENSITY
         STH,R5   DCT17,R1          SET FOLLOWON CODE
         B        FOLLOWON
*
REWIND   EQU      %                 DEVICE INTERRUPTS COME HERE
         LH,R5    DCT7,R1           DA(CLIST)
         LD,R8    DOUBLEZERO
         STD,R8   EOTSAV,R5         CLEAR END OF TAPE FLAG
         LI,R12   0                 NO XFER TYC
         LB,R6    IOQ4,R3           CALLING FUNCTION CODE
         CLM,R6   RFCODE            CALLER REWIND FUNCTION CODE
         BOL      REWINDA           NO-MUST BE CHANGE DENSITY SEQUENCE
         STD,R8   REWSAV,R5         YES-CLEAR REWIND FLAG
         B        EXITOK1           BACK TO CALLER
REWINDA  LD,R6    REWSAV,R5         REWIND FLAG
         BNEZ     REWIND2           THIS IS NOT THE FIRST DENSITY CHANGE
         LW,R8    Y8                FIRST TRY 1600 BPI
REWIND1  STW,R8   IOQ12,R3          INTO SEEK INFO
         AI,R6    1                 INDICATE BEEN HERE BEFORE
         STD,R6   REWSAV,R5         SAVE REWIND FLAG
         LI,R5    FCMC              FUNCTION CODE- MODE CONTROL
         STH,R5   DCT17,R1          INTO FOLLOWON
         B        FOLLOWON
REWIND2  CI,R6    2                 HERE FOR THE THIRD TIME
         BL       REWIND3           NO
         LI,R12   X'2800'           YES-KEY-IN REQUIRED
         LI,R13   FORMAT
         B        IOSCU             BACK TO IOQ
FORMAT   TEXTC    ' BAD TAPE FORMAT'
REWIND3  LW,R8    Y4                NEXT TRY 800 BPI
         B        REWIND1
         PAGE
         BOUND    8
MPCTIO   EQU      %                 MPC TAPE PRE HANDLER
         OR,R4    Y2                HOLD THE CHANNEL
         BAL,R10  COMLIST           GO BUILD CLIST
         PAGE
:DOT     CNAME
         PROC
         DO1      NUM(LF)=1
LF(1)    EQU      %-DOT
         GEN,8,8,8,8    BA(AF(1))-BA(DOT),AF(2),AF(3),AF(4)
         PEND
*
*        USER CALLABLE FUNCTION CODES.
*
DOT      EQU      %
FCRDF    :DOT     CLRDF,5,FCRDF,FCRDF1      0  READ FORWARD
FCWT     :DOT     CLWT,1,FCWT,FCWT1         1  WRITE TAPE
FCRDB    :DOT     CLSRB,5,FCRDB,FCRDBS1     2  READ BACKWARD
FCTM     :DOT     CLTM,1,FCTM,FCTM1         3  WRITE TAPE MARK
FCSRB    :DOT     CLSRB,5,FCSRB,FCSRB       4  SPACE RECORD BACKWARD
FCSRF    :DOT     CLSRF,5,FCSRF,FCSRF       5  SPACE RECORD FORWARD
FCSFB    :DOT     CLSFB,60,FCSFB,FCSFB      6  SPACE FILE BACKWARD
FCSFF    :DOT     CLSFF,60,FCSFF,FCSFF      7  SPACE FILE FORWARD
FCSRBRON :DOT     CLRWON,60,FCSRBRON        8  REWIND ON-LINE
FCSRBROF :DOT     CLRWOF,60,FCSRBROF        9  REWIND OFF-LINE
FCRWON   :DOT     CLRWON,60,FCRWON          A  REWIND ON-LINE
FCRWOF   :DOT     CLRWOF,60,FCRWOF          B  REWIND OFF-LINE
FCMC     :DOT     CLMC,1,FCMC,FCMC          C  MODE CONTROL
*
*        READ BACKWARD SIMULATION
*
FCRDBS1  :DOT     CLRDFS,5,FCRDBS1,FCRDBS2  D  GET BYTE COUNT
FCRDBS2  :DOT     CLSRB,5,FCRDBS2,FCRDBS3   E  POSITION TO READ
FCRDBS3  :DOT     CLRDB,5,FCRDBS3,FCRDBS4   F  READ AT CORRECT PLACE
FCRDBS4  :DOT     CLSRB,5,FCRDBS4           10 POSITION BACK
*
*        ERROR CORRECTION FUNCTION CODES.
*
SENSEVEC :DOT     CLSENSE,1,SENSEVEC        11 SENSE THEN ERROR VECTOR
SENSERTY :DOT     CLSENSE,1,SENSERTY        12 SENSE THEN RETRY
SENSEKEY :DOT     CLSENSE,1,SENSEKEY        13 SENSE THEN KEYIN
SENSERR  :DOT     CLSENSE,1,SENSERR         14 SENSE THEN STOP
*
*        READ FORWARD ERROR CORRECTION SEQUENCE.
*
FCRDF1   :DOT     CLSRB,5,FCRDF1,FCRDF2     15 SPACE RECORD BACK
FCRDF2   :DOT     CLRDF1,5,FCRDF2,FCRDF1    16 RE-READ THE RECORD
*
*        WRITE TAPE ERROR RECOVERY SEQUENCE.
*
FCWT1    :DOT     CLSRB,5,FCWT1,FCWT2       17 SRB OVER BAD WRITE
FCWT2    :DOT     CLSRB,5,FCWT2,FCWT3       18 SRB OVER LAST GOOD RECORD
FCWT3    :DOT     CLRDFS,5,FCWT3,FCWT4      19 GET BYTE COUNT OF LAST GOOD
FCWT4    :DOT     CLERS,1,FCWT4,FCWT5       1A ERASE TAPE
FCWT5    :DOT     CLWT,1,FCWT5,FCWT6        1B RE-WRITE RECORD
FCWT6    :DOT     CLSRB,5,FCWT6,FCWT7       1C SRB OVER RE-WRITE
FCWT7    :DOT     CLSRB,5,FCWT7,FCWT8       1D SRB OVER LAST GOOD RECORD
FCWT8    :DOT     CLRDFS,5,FCWT8,FCWT9      1E CHECK BYTE COUNT OF LAST
FCWT9    :DOT     CLRDFS,5,FCWT9,FCWT1      1F CHECK BYTE COUNT OF RE-WRITE
*
*        READ BACKWARD ERROR CORRECTION SEQUENCE.
*
FCRDB1   :DOT     CLSRB,5,FCRDB1,FCRDB2     20 SPACE OVER RECORD
FCRDB2   :DOT     CLRDB1,5,FCRDB2,FCRDBS4   21 RE-READ THE RECORD
*
*        TAPE MARK ERROR CORRECTION SEQUENCE.
*
FCTM1    :DOT     CLSRB,5,FCTM1,FCTM2       22 SRB OVER BAD TM
FCTM2    :DOT     CLERS,1,FCTM2,FCTM        23 ERASE TAPE
*
*        REWIND TO CHANGE DENSITY.
*
FCDENREW :DOT     CLDENREW,5,FCDENREW       24 REWIND TO CHANGE DEN.
         PAGE
:CLIST   CNAME
         PROC
         DO1      NUM(LF)=1
LF(1)    EQU      BA(%)
         LOCAL    I
I        DO       NUM(AF)
         DATA,1   DA(AF(1))-DA(DOT)
         FIN
         PEND
*
*        COMMAND LISTS FOR MPC
*
CLRDF    :CLIST   RDFCNTRL          READ FORWARD
         :CLIST   RDF
*
CLRDFS   :CLIST   RDFCNTRL          READ FORWARD WITH SKIP
         :CLIST   RDFS
*
CLRDB    :CLIST   RDBCNTRL          READ BACKWARD SIMULATION
*
CLRDF1   :CLIST   RDF1CTRL          ERROR CORRECTION READ FORWARD
         :CLIST   RDF
*
CLRDB1   :CLIST   RDB1CTRL          ERROR CORRECTION READ BACKWARD
*
CLWT     :CLIST   WTCNTRL           WRITE TAPE
         :CLIST   WT
*
CLTM     :CLIST   TMCNTRL           WRITE TAPE MARK
*
CLSRB    :CLIST   SRBCNTRL          SPACE RECORD BACKWARD
*
CLSRF    :CLIST   SRFCNTRL          SPACE RECORD FORWARD
*
CLSFB    :CLIST   SFBCNTRL          SPACE FILE BACKWARD
*
CLSFF    :CLIST   SFFCNTRL          SPACE FILE FOEWARD
*
CLRWON   :CLIST   RONCNTRL          REWIND ON LINE
*
CLRWOF   :CLIST   ROFCNTRL          REWIND OFF LINE
*
CLMC     :CLIST   MCCNTRL           MODE CONTROL
*
CLSENSE  :CLIST   SENSE             SENSE
*
CLERS    :CLIST   ERSCNTRL          ERASE TAPE
CLDENREW :CLIST   DENRCTRL          REWIND TO CHANGE DENSITY
         PAGE
SKIP     EQU      1                 SKIP FLAG
DC       EQU      X'8E'             DATA CHAIN
CC       EQU      X'2E'             COMMAND CHAIN
NCC      EQU      X'1E'             INTERRUPT AT CHANNEL END
DINT     EQU      X'0E'             WAIT FOR DEVICE INTERRUPT
*
:CDW     CNAME
         PROC
         BOUND    8
LF       GEN,8,24,8,8,8,8     AF(1),AF(2),AF(3),X'80',AF(4),AF(5)
         PEND
*
RDFCNTRL :CDW     X'03',RDFSETUP,CC,4,5 IDCW RDF SETUP
RDF      :CDW     X'02',0,NCC,2         READ FORWARD
*
RDFS     :CDW     X'02',0,NCC+SKIP      READ WITH SKIP
*
RDBCNTRL :CDW     X'03',RDBSETUP,CC,4,5 IDCW RDB SETUP
*
RDF1CTRL :CDW     X'03',RDF1SETP,CC,4,5  READ FORWARD ERROR CORR.
*
RDB1CTRL :CDW     X'03',RDB1SETP,CC,4,5  READ BACKWARD ERROR CORR.
*
WTCNTRL  :CDW     X'03',WTSETUP,CC,4,5   IDCW WT SETUP
WT       :CDW     X'01',0,NCC,2          WRITE TAPE
*
TMCNTRL  :CDW     X'03',TMSETUP,NCC,4,5  IDCW FOR TAPE MARK
*
SRBCNTRL :CDW     X'03',SRBSETUP,NCC,4,5 IDCW SRB SETUP
*
SRFCNTRL :CDW     X'03',SRFSETUP,NCC,4,5 IDCW SRF SETUP
*
SFBCNTRL :CDW     X'03',SFBSETUP,NCC,4,5 IDCW SFB SETUP
*
SFFCNTRL :CDW     X'03',SFFSETUP,NCC,4,5 IDCW SFF SETUP
*
RONCNTRL :CDW     X'03',RONSETUP,DINT,4,5 IDCW RON SETUP
*
ROFCNTRL :CDW     X'03',ROFSETUP,DINT,4,5 IDCW ROF SETUP
*
MCCNTRL  :CDW     X'03',MCSETUP,NCC,4,5  IDCW MODE CONTROL SETUP
*
SENSE    :CDW     X'04',SENSETUP,NCC,4,5 SENSE SETUP
*
ERSCNTRL :CDW     X'03',ERSSETUP,NCC,4,5 IDCW FOR ERASE TAPE
DENRCTRL :CDW     X'03',RONSETP1,DINT,4,5 CHANFE DEN
         PAGE
:VEC     COM,8    AF-MPCT
*
SVEC     EQU      %                 AFTER SENSE VECTOR
         :VEC     EVECTOR           SENSE THEN ERROR VECTOR
         :VEC     SRTY                         DOT RETRY FC
         :VEC     OPERA                        KEYIN
         :VEC     STOP                         STOP
         BOUND    4
         PAGE
NVEC     EQU      %                 NORMAL COMPLETION VECTOR
         :VEC     EXITOK            0  READ RORWARD
         :VEC     EXITOK            1  WRITE TAPE
         :VEC     READREV           2  READ BACKWARD
         :VEC     EXITOK            3  WRITE TAPE MARK
         :VEC     SPAC:REC          4  SPACE RECORD BACKWARD
         :VEC     SPAC:REC          5  SPACE RECORD FORWARD
         :VEC     SPAC:FIL          6  SPACE FILE BACKWARD
         :VEC     SPAC:FIL          7  SPACE FILE FORWARD
         :VEC     EXITOK            8  REWIND ON LINE
         :VEC     EXITOK            9  REWIND OFF LINE
         :VEC     EXITOK            A  REWIND ON LINE
         :VEC     EXITOK            B  REWIND OFF LINE
         :VEC     MODECNTL          C  MODE CONTROL
*
*        READ BACKWARD SIMULATION
*
         :VEC     SKIPREAD          D  GET BTYE COUNT
         :VEC     READREVA          E  POSITION TO READ
         :VEC     SAVDCT13          F  READ AT CORRECT ADDRESS
         :VEC     READREVB          10 POSITION BACK
*
*        ERROR CORRECTION FUNCTION CODES.
*
         :VEC     SENSDONE          11 SENSE THEN ERROR VECTOR
         :VEC     SENSDONE          12 SENSE THEN RETRY
         :VEC     SENSDONE          13 SENSE THEN KEYIN
         :VEC     SENSDONE          14 SENSE THEN STOP
*
*        READ FORWARD CORRECTION SEQUENCE
*
         :VEC     FOLLOWON          15 SPACE RECORD BACK
         :VEC     EXITOK            16 RE-READ THE RECORD
*
*        WRITE TAPE CORRECTION SEQUENCE.
*
         :VEC     FOLLOWON          17 SRB OVER BAD WRITE
         :VEC     ERASECNT          18 SRB OVER LAST GOOD RECORD
         :VEC     SKIPREAD          19 GET BYTE COUNT OF LAST GOOD
         :VEC     ERSE              1A ERASE TAPE
         :VEC     SAVDCT13          1B RE-WRITE RECORD
         :VEC     FOLLOWON          1C SRB OVER RE-WRITE
         :VEC     FOLLOWON          1D SRB OVER LAST GOOD RECORD
         :VEC     SKIPREAD          1E CHECK BYTE COUNT LAST GOOD
         :VEC     CHECKCNT          1F CHECK BYTE COUNT OF RE-WRITE
*
*        READ BACKWARD ERROR CORRECTION SEQUENCE.
*
         :VEC     READBERA          20 SRB OVER RECORD
         :VEC     SAVDCT13          21 RE-READ RECORD
*
*        TAPE MARK ERROR CORRECTION SEQUENCE.
*
         :VEC     FOLLOWON          22 SRB OVER BAD TM
         :VEC     FOLLOWON          23 ERASE TAPE
*
*        REWIND TO CHANGE DENSITY.
*
         :VEC     EXITOK            24 REWIND TO CHANGE DENSITY
         BOUND    4
         PAGE
EVEC     EQU      %                 ERROR VECTOR (TAPE MOVEMENT OR MC)
         :VEC     NOISE             0  READ FORWARD
         :VEC     FOLLOWON          1  WRITE TAPE
         :VEC     STOP              2  READ BACKWARD
         :VEC     FOLLOWON          3  WRITE TAPE MARK
         :VEC     STOP              4  SPACE RECORD BACKWARD
         :VEC     STOP              5  SPACE RECORD FORWARD
         :VEC     STOP              6  SPACE FILE BACKWARD
         :VEC     STOP              7  SPACE FILE FORWARD
         :VEC     STOP              8  REWIND ON LINE
         :VEC     STOP              9  REWIND OFF LINE
         :VEC     STOP              A  REWIND ON LINE
         :VEC     STOP              B  REWIND OFF LINE
         :VEC     FOLLOWON          C  MODE CONTROL
*
*        READ BACKWARD SIMULATION
*
         :VEC     SKIPRERR          D  GET BYTE COUNT
         :VEC     STOP              E  POSITION TO READ
         :VEC     READBERR          F  READ AT CORRECT ADDRESS
         :VEC     STOP              10 POSITION BACK
*
*        ERROR CORRECTION FUNCTION CODES.
*
         :VEC     STOP              11 SENSE THEN ERROR VECTOR
         :VEC     STOP              12 SENSE THEN RETRY
         :VEC     STOP              13 SENSE THEN KEYIN
         :VEC     STOP              14 SENSE THEN STOP
*
*        READ FORWARD ERROR CORRECTION SEQUECE.
*
         :VEC     STOP              15 SPACE RECORD BACK
         :VEC     FOLLOWON          16 RE-READ THE RECORD
*
*        WRITE TAPE ERROR RECOVERY SEQUENCE.
*
         :VEC     STOP              17 SRB OVER BAD WRITE
         :VEC     STOP              18 SRB OVER LAST GOOD RECORD
         :VEC     STOP              19 GET BYTE COUNT LAST GOOD REC
         :VEC     STOP              1A ERASE TAPE
         :VEC     REWRTERR          1B RE-WRITE RECORD
         :VEC     STOP              1C SRB OVER RE-WRITE
         :VEC     STOP              1D SRB OVER LAST GOOD RECORD
         :VEC     STOP              1E CHECK BYTE COUNT OF LAST GOOD
         :VEC     FOLLOWON          1F CHECK BYTE COUNT OF RE-WRITE
*
*        READ BACKWARD ERROR CORRECTION SEQUENCE.
*
         :VEC     STOP              20 SRB OVER RECORD
         :VEC     READBERR          21 RE-READ THE RECORD
*
*        TAPE MARK ERROR CORRECTION SEQUENCE.
*
         :VEC     STOP              22 SRB OVER BAD TM
         :VEC     STOP              23 ERASE TAPE
*
*        REWIND TO CHANGE DENSITY.
*
         :VEC     STOP              24 REWIND TO CHANGE DENSITY
         BOUND    4
         PAGE
ERSSETUP LD,R12   ERASE             IDCW
         B        SETUP
*
RDF1SETP EQU      %                 READ FORWARD WITH CORRECTION
         LI,R15   SETUP             RETURN ADDRESS
         B        RDERSTEP          CHANGE IDCW IF NEEDED
*
WTSETUP  LD,R12   WRITE             WRITE IDCW
         B        SETUP
*
TMSETUP  LD,R12   TAPEMARK          IDCW
         B        SETUP
*
SRBSETUP LD,R12   SPACERBK          IDCW
         B        SETUP
*
SRFSETUP LD,R12   SPACERFW          IDCW
         B        SETUP
*
SFBSETUP LD,R12   SPACEFBK          IDCW
         B        SETUP
*
SFFSETUP LD,R12   SPACEFFW          IDCW
         B        SETUP
*
RONSETUP OR,R4    YC                SET COMPLETE IN DCB RIGHT AWAY
RONSETP1 LD,R12   REWINDON          IDCW
         OR,R4    Y8                FREE THE CHANNEL-CHANGE DENSITY REW
         B        SETUP
*
ROFSETUP LD,R12   REWINDOF          IDCW
         OR,R4    YC                SET COMPLETE IN DCB RIGHT AWAY
         B        SETUP
*
MCSETUP  EQU      %
         LW,R5    IOQ12,R3          SEEK INFO
         LD,R12   1600BPI           ASSUME 1600 BPI
         CW,R5    Y8                1600 BPI CALLED
         BANZ     SETUP             YES
         LD,R12   800BPI            NO-MUST BE 800BPI
         B        SETUP
*
SENSETUP EQU      %
         LH,R5    DCT7,R1           DA(CLIST)
         AI,R5    SENSEBUF          DA DISPLACEMENT OF SENSE BUFFER
         B        SETUPA
*
RDFSETUP LD,R12   READ              READ IDCW
*
SETUP    EQU      %
         BAL,R0   DEVNUM            PUT DEVICE NUMBER IN IDCW
         LH,R5    DCT7,R1           DA(CLIST)
         AI,R5    IDCW              DA DISPLACEMENT OF IDCW
         BAL,R0   RE:ENT            ARE WE THE LAST ENTRY
         STD,R12  0,R5              PUT IDCW IN CLIST
         ENABLE
SETUPA   EQU      %                 ENTER FROM SENSE
         AND,R8   YFF               CLEAN FIST WORD OF CDW
         SLS,R5   3                 MAKE BYTE ADDRESS OF IDCW
         OR,R8    R5                  INTO CDW
         AND,R9   NBYT2             CLEAN SECOND WORD OF CDW
         B        USECOM            BACK TO COMLIST TO USE THIS CDW
*
*
RDBSETUP EQU      %                 READ BACKWARD SETUP
         LD,R12   READ              READ IDCW
RDBSET1  EQU      %                 COME IN FROM ERROR CORRECTION
         BAL,R0   DEVNUM            PUT DEVICE NIMBER IN IDCW
         LH,R5    DCT7,R1           DA(CLIST)
         AI,R5    IDCW              DA DISPLACEMENT TO IDCW
         AND,R8   YFF               CLEAN FIRST WORD OF CDW
         SLS,R5   3                 MAKE BYTE ADDRESS IF IDCW
         OR,R8    R5                  INTO CDW
         SLS,R5   -3                BACK TO DA
         AND,R9   NBYT2             CLEAN SECOND WORD OF CDW
         BAL,R0   RE:ENT            ARE WE THE LAST ENTRY
         STD,R12  0,R5              PUT IDCW INTO CLIST
         AI,R5    -IDCW             DA(CLIST)
         STD,R8   0,R5              PUT CONTROL ENTRY INTO CLIST
         ENABLE
         LH,R0    DCT7,R1           DA(CLIST)
         B        IOSST             BACK TO IOQ TO DO IO
*
RDB1SETP EQU      %                 READ BACKWARD ERROR CORRECTION
         BAL,R15  RDERSTEP          GET CORRECTED IDCW
         B        RDBSET1           GO INTO NORMAL READ REV CODE
*
*
RDERSTEP EQU      %                 SETUP IDCW FOR READ CORRECTION
         LH,R5    DCT7,R1           DA(CLIST)
         LD,R12   CORRDSAV,R5       CORRECTABLE READ ERROR FLAG
         MTW,0    R13               CORRECTABLE READ ERROR
         BEZ      RDERSTP1          NO
         LI,R13   0                 YES-CLEAR FLAG
         BAL,R0   RE:ENT            LAST ENTRY
         STD,R12  CORRDSAV,R5           IN CLIST
         ENABLE
         LD,R12   READ              READ IDCW
         B        *R15              RETURN
*
RDERSTP1 LD,R12   READ              READ IDCW
         LB,R10   IOQ10,R3          INITIAL RETRY COUNT
         LB,R11   IOQ11,R3          CURRENT RETRY COUNT
         SW,R10   R11               NUMBER OF TIMES HERE
         AND,R10  M3                MOD 8
         SLS,R10  2                 POSITION FOR IDCW
         AW,R12   R10               INC IDCW BY TIMES HERE
         LI,R10   DOT               SET BACK UP FOR IOQ
         B        *R15              RETURN
         PAGE
DEVNUM   EQU      %                 PUT DRIVE NUMBER IN IDCW
         LH,R5    DCT1P,R1
         AND,R5   M4                DRIVE NUMBER
         SLS,R5   20                POSITION FOR IDCW
         OR,R12   R5                DRIVE NUMBER INTO IDCW
         B        *R0
         PAGE
*
*        IDCW PICTURE
*
*0       *6        *12      *18  *21 * 22 * 23 *24           *30-->63
*--------*---------*--------*----*---*----*----*-------------*---->
*        *         *        *    *   *    *    *             *    >
* DEVICE * DEVICE  * MBZ    * 7  * M * C  * M  * CHANNEL     * S  >
* INST   * ADDRESS * FIELD  *    * A * O  * A  * INST        * P  >
* FIELD  * FIELD   * AREA   *    * S * N  * R  * FIELD       * I  >
*        *         *        *    * K * T  * K  *             * L  >
*        *         *        *    *   *    *    *             *    >
*--------*---------*--------*----*---*----*----*-------------*---->
         PAGE
:IDCW    CNAME
         PROC
         BOUND    8
LF       SET      %
         GEN,6,6,6,3,1,1,1,6,6,28    CF(2),;  DEVICE COMMAND
                                         0,;  DEVICE ADDRESS
                                         0,;  MBZ
                                         7,;  MUST BE ALL ONES
                                         0,;  MASK FIELD
                                     AF(1),;  CONTINUE BIT
                                         0,;  MARK BIT
                                     AF(2),;  CHANNEL INSTRUCTION
                                     AF(3),;  PRECORD COUNT
                                         0    SPILL FOR SIGMA D/W
         PEND
*
*        IDCW STATIC DATA AREA
*
ERASE    :IDCW,X'2C'  0,2
WRITE    :IDCW,X'0B'                WRITE 9 TRACK
TAPEMARK :IDCW,X'2D'  0,2
SPACERBK :IDCW,X'26'  0,2,1
SPACERFW :IDCW,X'24'  0,2,1
SPACEFBK :IDCW,X'27'  0,2
SPACEFFW :IDCW,X'25'  0,2
REWINDON :IDCW,X'38'  0,2
REWINDOF :IDCW,X'3A'  0,2
1600BPI  :IDCW,X'35'  0,2
800BPI   :IDCW,X'30'  0,2
READ     :IDCW,X'03'  0,X'10'       READ 9 TRACK- NO RETRY
         END

