         DEF      MTAP:
MTAP:    EQU      %
*
         SYSTEM   UTS
*
*
         DEF      MTAP,MTAPCU
         DEF      NOTOPTST,VECT5
*
*
         REF      MAGTAPE,VECT1,VECT4,9TDOT,MT64
         REF      NEWERCK
         REF      EXITRTY,EXITIS,EXITEOT,EXITBOT,EXITTM
         REF      EXITBOTT,EXITTMT,EXITEOTT,EXTREVCK
         REF      EXITGOOD,EXITFOL,EXITNOT,EXTERASE
         REF      DCT7,DCT8,DCT17
         REF      IOQ4,IOQ5,IOQ8,IOQ11
         REF      RE:ENT,COMLIST,IOSCU,MSG5,MSG9
         REF      Y2,X1FFFF
*
         SREF     7TAP,7TAP20
*
*
         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
R8       EQU      8
R9       EQU      9
R10      EQU      10
R11      EQU      11
R12      EQU      12
R13      EQU      13
R14      EQU      14
R15      EQU      15
*
*
*        TYC CODES
*
TYCOK    EQU      1                 SUCCESS
TYCBOT   EQU      3                 LOAD POINT
TYCEOT   EQU      5                 END OF TAPE
TYCTM    EQU      6                 TAPE MARK (END OF FILE)
TYCERR   EQU      8                 ERROR
*
*        FLAGS
*
FLGRETRY EQU      X'8000'
FLGFOLOW EQU      X'4000'
FLGINTER EQU      X'2000'
FLGKEYNC EQU      X'800'
FLGHOLD  EQU      X'400'
*
*        ORDER CODES
*
RDBCODE  EQU      12                READ BACKWARD
SRBCODE  EQU      75                SPACE RECORD BACKWARD
SFBCODE  EQU      91                SPACE FILE BACKWARD
SECODE   EQU      99                SET ERASE
RWONCODE EQU      19                REWIND ON-LINE
RWOFCODE EQU      35                REWIND OFF-LINE
*
*        SPECIAL CLIST AREA WORDS
*
SENSEBUF EQU      2                 SENSE DATA BUFFER, WDS 2-5
FUNCSAVE EQU      6                 CURRENT FUNCTION SAVE AREA
BYTESKIP EQU      7                 WT RECOVERY REV READ BYTE COUNTER
ERASEBUF EQU      7
*
*
MAXERASE EQU      10                MAX # OF 3 1/2 INCH ERASURES,WT RCV
*
         PAGE
************************************
*   9T TAPE PRE-PROCESSOR          *
************************************
MTAP     EQU      %
         LI,R10   9TDOT
         OR,R4    Y2                HOLD CHAN FOR POSSIBLE SENSE
         B        COMLIST
*
*
         PAGE
************************************
*   9T TAPE POST-PROCESSOR         *
************************************
MTAPCU   EQU      %
         LB,R4    IOQ5,R3           GET CURRENT FUNCTION
         BAL,R0   RE:ENT
         ENABLE
         BAL,R7   NEWERCK           GENERAL ERROR TESTS
         B        MTAP05            POSSIBLE ERRORS FOUND
         LB,R7    VECT1,R4          NO ERRORS; GET INDEX FOR
*                                    NO ERROR CLEANUP
         B        MAGTAPE,R7        GO TO N0-ERROR-CLEANUP
MTAP05   EQU      %
         BAL,R15  NOTOPTST          CHK FOR ERRORS, NOT
*                                    DEPENDENT ON FUNCTION
*        IF WE RETURN HERE, NO INDEPENDENT ERRORS WERE FOUND.
*        ANALYZE THE FUNCTION DEPENDENT ERRORS.
*
         LB,R7    VECT3,R4          GET INDEX FOR FUNCTION
*                                    DEPENDENT ERROR ANALYSIS
         LW,R4    IOQ8,R3           IS IT A DATA CHAINED CLIST
         BLZ      %+2               YES, IOCD'S ARE IN AN MPOOL
         LH,R4    DCT7,R1           GET CLIST AREA ADR
         SLS,R4   1                 MAKE IT A WORD ADR
         LB,R4    *R4               GET I/O ORDER FROM IOCD
         B        MTAPCU,R7         GO TO ERROR ANALYSIS
*
         PAGE
*
*        ERROR CHECK FOR 'WRITE' AND 'WRITE TAPE MARK'
*
MTAP10   EQU      %
         CI,R5    X'60'             TDV9,10  TME,TDE
         BANZ     MTAP16            ERASE AND REWRITE
         CI,R5    X'4000'           TDV1, WRITE RING INSTALLED
         BANZ     MTAP17            YES
         LI,R12   FLGKEYNC          NO
         LI,R13   MSG5
         B        IOSCU
MTAP16   EQU      %
         LH,R6    DCT7,R1           CLEAR 'ERASEBUF' AND  'BYTESKIP'
         SLS,R6   1
         LI,R7    0
         BAL,R0   RE:ENT
         STW,R7   BYTESKIP,R6
         LB,R7    IOQ11,R3          GET REMAINING RETRIES
         CI,R7    MAXERASE          WILL THEY ERASE TOO MUCH TAPE
         BLE      %+2               NO
         LI,R7    MAXERASE          YES, FORCE TO MAX
         SLS,R6   1                 HW ADR
         STH,R7   ERASEBUF,R6       SAVE ERASE COUNT
         B        EXITRTY
MTAP17   EQU      %
         CI,R5    X'200'            TDV6, EOT
         BAZ      EXITIS            UNKNOWN ERROR, INCONSISTENT STATUS
         LB,R5    IOQ5,R3           GET CURRENT FUNCTION
         CB,R5    IOQ4,R3           IS IT REQUESTED FUNCTION
         BE       EXITEOT           YES, REPORT EOT
         LB,R7    IOQ11,R3          GET RETRIES REMAINING
         BGZ      MTAP18            SOME LEFT
         LI,R12   X'13'             NONE LEFT; REPORT WT ERROR AT EOT
         B        IOSCU
MTAP18   EQU      %
         LI,R7    1                 ALLOW ONE RETRY AT EOT
         BAL,R0   RE:ENT
         STB,R7   IOQ11,R3
         LB,R7    VECT1,R5          CONTINUE RECOVERY SEQUENCE
         LW,R8    DCT8,R1           IS THIS 7-TRACK TAPE
         AND,R8   X1FFFF
         CI,R8    7TAP
         BNE      MAGTAPE,R7        NO
         LB,R7    VECT4,R5          YES
         B        MAGTAPE,R7
*
         PAGE
*
*        ERROR CHECK FOR 'READ' ORDERS
*
MTAP20   EQU      %
         CI,R5    X'60'             TDV9,10 TME,TDE
         BAZ      MTAP22
         CI,R5    X'800'            TDV4, NON-CORRECTABLE READ ERROR
         BAZ      MTAP28            CORRECTABLE
         LW,R8    DCT8,R1           NON-CORRECTABLE
         AND,R8   X1FFFF
         CI,R8    7TAP              IS IT 7-TRACK
         BNE      EXITRTY           NOT 7-TRACK
         B        7TAP20            DO 7T REV READ CHECKS
MTAP22   EQU      %
*                                   NO TRANSMISSION ERRORS
         CI,R5    X'400'            TDV5, BOT
         BAZ      MTAP24            NOT LOAD POINT
         CI,R4    RDBCODE           IS IT READ BACKWARD
         BE       EXITBOT           YES, REPORT LOAD POINT
         B        EXITIS            NO, INCONSISTENT STATUS
MTAP24   EQU      %
         CI,R5    X'1000'           TDV3, TM
         BANZ     EXITTM            REPORT END OF FILE
         CI,R5    X'200'            TDV6, EOT
         BAZ      EXITIS            UNKNOWN CONDITION
         CI,R4    RDBCODE           IS IT READ BACKWARD
         BE       EXITIS            YES, BAD STATUS
         LW,R8    DCT8,R1           IS THIS 7-TRACK TAPE
         AND,R8   X1FFFF
         CI,R8    7TAP
         BNE      EXITEOT           NO, REPORT EOT
         B        EXTREVCK          YES, CHK FOR REV READ
MTAP28   EQU      %
         LH,R5    DCT17,R1          RETRY WITH  FOLLOW-ON CODE
         SLS,R5   8
         BAL,R0   RE:ENT
         STH,R5   DCT17,R1
         LI,R12   FLGRETRY+FLGINTER+FLGHOLD+TYCERR
         B        IOSCU
*
         PAGE
*
*        ERROR CHECK FOR 'SPACE RECORD' ORDERS
*
MTAP30   EQU      %
         CI,R5    X'400'            TDV5, BOT
         BAZ      MTAP34
         CI,R4    SRBCODE           IS IT SPACE RECORD BACK
         BE       EXITBOTT          YES, TEST FOR PRECORD
         B        EXITIS            NO, BAD STATUS
MTAP34   EQU      %
         CI,R5    X'1000'           TDV3, TM
         BANZ     EXITTMT           TEST FOR PRECORD
         CI,R5    X'200'            TDV6, EOT
         BAZ      EXITIS            BAD STATUS
         CI,R4    SRBCODE
         BNE      EXITEOTT
         B        EXITIS
*
         PAGE
*
*        ERROR CHECK FOR 'SPACE FILE' ORDERS
*
MTAP40   EQU      %
         CI,R4    SFBCODE           IS IT SPACE FILE BACK
         BE       MTAP44            YES
         CI,R5    X'200'            TDV6, EOT
         BANZ     EXITEOTT          TEST FOR PFIL
         B        EXITIS            BAD STATUS
MTAP44   EQU      %
         CI,R5    X'400'            TDV5, BOT
         BANZ     EXITBOT           REPORT LOAD POINT
         B        EXITIS            BAD STATUS
*
         PAGE
*
*        ERROR CHK FOR 'REWIND', 'SENSE', 'SET CORRECTION'
*        AND 'SET ERASE'
*
MTAP50   EQU      %
         CI,R4    RWONCODE          IS IT ON-LINE REWIND
         BE       MTAP54            YES
         CI,R4    RWOFCODE          IS IT OFF-LINE REWIND
         BE       MTAP54            YES
         CI,R5    X'60'             TDV9,10  TME,TDE
         BAZ      EXITIS            BAD STATUS
         LI,R12   FLGKEYNC          ASK OPERATOR TO RETRY
         LI,R13   MSG9              'REQ RETRY' MESSAGE
         B        IOSCU
MTAP54   EQU      %
         CI,R5    X'400'            TDV5,BOT
         BANZ     EXITGOOD          REWIND FINISHED AT LOAD PT
         B        EXITRTY           NOT AT LOAD POINT, TRY AGAIN
*
         PAGE
*
*        PHONEY GAP TEST FOR 9T WRITE RECOVERY
*        FUNCTION WAS A 'READ BACKWARD WITH SKIP'
*
MTAP60   EQU      %
         CI,R5    X'60'             TDV9,10  TME,TDE
         B        MT64
*
         PAGE
*
*        ERASE TAPE DECISION FOR 9T WRITE RECOVERY
*        FUNCTION WAS A 'SPACE RECORD BACKWARD'
*
MTAP70   EQU      %
         CI,R5    X'1400'           TDV3,5  TM,BOT
         BAZ      EXITIS            UNKNOWN CONDITION
         B        EXTERASE
*
         PAGE
*
*        FUNCTION INDEPENDENT ERROR CHECK
*
NOTOPTST EQU      %
         CI,R8    X'6600'           TIO1,2,5,6  OPERATIONAL STATUS
         BANZ     EXITNOT           NOT OPERATIONAL
         CI,R5    X'1E'             TDV11-14  IOP ERROR
         BANZ     EXITIS            POSITION UNKNOWN
         B        *15
*
*
*
EXITBAD  EQU      %
         B        EXITIS
*
EXITFOLL EQU      %
         B        EXITFOL
*
         PAGE
*
*        WANG, POTTER 9-TRACK TAPE
*        ERROR BRANCH TABLE
*
:BCH3    COM,8    AF(1)-MTAPCU
         BOUND    4
*
VECT3    EQU      %
         :BCH3    MTAP20             0 RDF
         :BCH3    MTAP10             1 WT
         :BCH3    MTAP20             2 RDB
         :BCH3    MTAP10             3 TM
         :BCH3    MTAP30             4 SRB
         :BCH3    MTAP30             5 SRF
         :BCH3    MTAP40             6 SFB
         :BCH3    MTAP40             7 SFF
         :BCH3    EXITFOLL           8 SRB-REW-ON
         :BCH3    EXITFOLL           9 SRB-REW-OFF
         :BCH3    MTAP50            10 REW-ON
         :BCH3    MTAP50            11 REW-OFF
         :BCH3    EXITBAD           12 NS MODE CONTROL
         :BCH3    MTAP50            13 SENSE,NRZI RDF CORR RCV
         :BCH3    MTAP30            14 SRB, NRZI RDF CORR RCV
         :BCH3    MTAP50            15 SC
         :BCH3    MTAP50            16 SENSE,NRZI RDB CORR RCV
         :BCH3    MTAP30            17 SRF, NRZI RDB CORR RCV
         :BCH3    MTAP50            18 SC
         :BCH3    MTAP30            19 SRB,RDF NON-CORR RECOV
         :BCH3    MTAP30            20 SRF,RDB NON-CORR RECOV
         :BCH3    MTAP30            21 SRB, TM RECOVERY
         :BCH3    EXITFOLL          22 SC,NS-NRZI WT RECOV
         :BCH3    MTAP30            23 SRB OVER BAD WRITE
         :BCH3    MTAP10            24 TM
         :BCH3    MTAP30            25 SRB OVER TM
         :BCH3    MTAP60            26 RDB WITH SKIP
         :BCH3    MTAP40            27 SFF
         :BCH3    MTAP28            30 SRF OVER GOOD RECORD
         :BCH3    MTAP10            29 TM
         :BCH3    MTAP70            30 SRB OVER TM
*
         PAGE
*
*        7-TRACK TAPE
*        ERROR BRANCH TABLE
*
:BCH5    COM,8    AF(1)-MTAPCU
         BOUND    4
*
VECT5    EQU      %
         :BCH5    MTAP20             0 RDPF
         :BCH5    MTAP10             1 WTP
         :BCH5    MTAP30             2 RDPB
         :BCH5    MTAP10             3 TM7
         :BCH5    MTAP30             4 SRB7
         :BCH5    MTAP30             5 SRF7
         :BCH5    MTAP40             6 SFB7
         :BCH5    MTAP40             7 SFF7
         :BCH5    MTAP50             8 REW-ON
         :BCH5    MTAP50             9 REW-OFF
         :BCH5    MTAP20            10 RDBF
         :BCH5    MTAP10            11 WTB
         :BCH5    MTAP30            12 RDBB
         :BCH5    MTAP20            13 RDDF
         :BCH5    MTAP10            14 WTD
         :BCH5    MTAP30            15 RDDB
         :BCH5    MTAP30            16 RDPF RECOVERY
         :BCH5    MTAP30            17 WTP RECOVERY
         :BCH5    MTAP50            18 WTP RECOVERY
         :BCH5    MTAP30            19 TM7 RECOVERY
         :BCH5    MTAP50            20 TM7 RECOVERY
         :BCH5    MTAP30            21 RDBF RECOVERY
         :BCH5    MTAP30            22 WTB RECOVERY
         :BCH5    MTAP50            23 WTB RECOVERY
         :BCH5    MTAP30            24 RDDF RECOVERY
         :BCH5    MTAP30            25 WTD RECOVERY
         :BCH5    MTAP50            26 WTD RECOVERY
         :BCH5    MTAP20            27 RDPB FOLLOW-ON
         :BCH5    MTAP30            28 RDPB FOLLOW-ON
         :BCH5    MTAP20            29 RDBB FOLLOW-ON
         :BCH5    MTAP30            30 RDBB FOLLOW-ON
         :BCH5    MTAP20            31 RDDB FOLLOW-ON
         :BCH5    MTAP30            32 RDDB FOLLOW-ON
         :BCH5    MTAP30            33 FINAL SRB,RECOVERED REV RDS
         :BCH5    MTAP30            34 FINAL SRB,FAILED REV RDS
*
         END

