         DEF      T:DSMNT
T:DSMNT  EQU      %
ANSPROC  SET      1
         SYSTEM   UTS
*
*
*
*
*
*
         PAGE
*                 SYMBOLIC REGISTER DEF'S.
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
         REF      DOUBLEZERO
         REF      AVRTBL,AVRTBLSIZ,J:JIT,AVRID
         REF      DCT4
         REF      AVRTBLNE
         REF      AVRNOU
         REF      LSERIAL
         REF      BATAPE,S:CUN
         REF      SH:RBCU,SH:ROCU,SH:RGCU
         REF      S:GSPIN
         REF      JB:MAX,JB:CUR,S:MBSF
         REF,1    JB:XLNK,JB:SLNK
         REF      PLH:FLG,PL:JIF
         REF      PLD:ACT,PLH:SID,PLB:USR
         REF      Y02,X0,Y18
         REF      DCT16
         REF      ASPIN,DEALL,DHHIT,GETRAT,HOWALO
         REF      RSETSPIN,SC31,RAT:DCT4,RSERIAL
         REF      X1000FFFF
         REF      ANSFLGS,AVRFNMT,XA
         SPACE    3
         REF      Y8
         REF      J:AMR,RBG
         REF      Y1,MSROCTY
         DEF      T:DSMT
T:DSMT   RES      0
         PUSH     7,R5
         LW,SR1   J:AMR
         BEZ      %+2
         BAL,SR4  RBG
         LW,7     TSTACK
         AI,7     2
         LI,6     7
         BUMP     11,R4             SET UP BUFFER
         LW,D4    CKMESS-1,6
         STW,D4   *7,6
         BDR,6    %-2
         LW,D4    Y8
         STW,D4   -1,7
         AI,R7    1
         STW,R7   -1,7              BUFF
         AI,R7    -2                PLIST
         LI,R5    J:JIT
         LI,SR1   2
*
*
         LI,3     -1
         LI,2     0                 DCTX
CKFF     AI,2     1
         CI,2     BATAPE+AVRTBLSIZ
         BGE      CKPULL            DISLK
         CI,2     BATAPE
         BL       CKJD              DEALLOC AND RESET SPIN
*        TAPE
         AI,3     1                 AVRX
         LW,0     S:CUN
         CH,0     AVRID,3
         BE       CKF1
         B        CKFF
*PACK LOGIC
*                                   FINISHED
CKPULL   RES     0
         BUMP     -11,R4
PACK     AI,3     1
         CI,2     BATAPE+AVRTBLNE
         BGE      DONE
*        2-DCT     3-AVR
         LI,14    0
SPO      BAL,11   DHHIT
         BAZ      SP1               NO
         BAL,11   ASPIN             RSET ASPIN AND LOAD 15
         MTH,-1   AVRNOU,3
         BNEZ     SP1               NO RELEASE
         LD,D1    AVRTBL,3
         AND,D2   XFFFF
         REF      XFFFF
         STD,D1   AVRTBL,3          CLEAR NOU  DEV PACK
*        FIN OUT WHERE TO RELEASE
         BAL,11   HOWALO            RESET SPIN AND HOW ALLO IN 0
         BAL,11   RAT:DCT4          1=RATX
         B        SC31              NO FIND
         MTH,0    AVRID,3           LOCKED?
         BLEZ     COUNTIT           LOCKED OR SHARED
         LC       J:JIT
         BCR,12   SP1               BATCH EXCL-DO'T COUNT
COUNTIT  RES      0
         MTH,-1   *0,1
SP1      LW,15    S:CUN
         CH,15    AVRID,3
         BNE      %+2
         STH,14   AVRID,3
         AI,2     1
         B        PACK
DONE     RES      0                 ALL DONE WITH SPIN'S
         LI,7     0
         LC       J:JIT
         BCS,12   SP2
         LI,5     JB:PNR
         LB,5     0,5
         REF,1    JB:PNR
         STB,7    PLB:USR,5         ZAP USER #
         STD,7    PLD:ACT,5         ZAP ACCOUNT
         STH,7    PLH:SID,5         ZAP ID
         LH,7     PLH:FLG,5         RESET JOB DEPENDENT FLAGS
         AND,7    PL:JIF            JOB INDEPENDENT FLAGS MASK
         STH,7    PLH:FLG,5
         REF      PLB:MIN
         MI,R5    SV:RSIZ+1
        LI,7     0
         STB,7    PLB:MIN,R5       CLEAR EXCLSIVE LINK
         REF      SV:RSIZ
         LI,7     SV:RSIZ
RELRES   LB,5     JB:MAX,7
         REF      M7
         CI,7     1
         BNE      %+4
         MTB,0    JB:MAX
         BNEZ     %+2
         SLS,5    -1
         AND,5    M7
         LCW,5    5
         AH,5     SH:RBCU,7
         STH,5    SH:RBCU,7
         BDR,7    RELRES            - NEXT RES REL
         LI,5     JB:SLNK-BA(LSERIAL)
SCABORT  RES      0                 TYPE NOT FOUND GO ON
SERIAL   LW,6     5
J11      LB,5     LSERIAL,6
         BEZ      SERIALE
         LB,4     RSERIAL,5         TYPE
         BAL,11   GETRAT
         B        SCABORT           NO FIND
         MTH,-1   SH:RBCU,1         FIND
         B        SERIAL
SERIALE  RES      0
         LI,5     JB:XLNK           NOW CHAIN BOTH X&S TO FREE CHAIN
         LB,5     0,5               ARE THERE ANY
         STB,5    LSERIAL,6         LINK BOTH TOGETHER
         LW,5     6
         LB,6     LSERIAL,5         FIND END OF CHAIN
         BNEZ     %-2
         LI,6     JB:SLNK           GET HEAD
         LB,6     0,6
         BEZ      SP2               NONE ATALL
         WD,0     X'37'             DISABLE
         LB,7     LSERIAL           HEAD OF FREE ENTRIES
         STB,7    LSERIAL,5         LINK NEW CHAIN
         STB,6    LSERIAL           NEW HEAD
         WD,0     X'27'             ENABLE
SP2      EQU      %
         STW,11   S:MBSF            SET MBS FLAG
CNM      EQU      1                 TEMP CARD********************
         DO       CNM
*
*        CLEAR ANY SLAVE LINES BELONGING TO THIS USER
*
         REF      MODE5,LB:UN,KILLIO,LNOL,DCTSIZ
         REF      DCT23,SLVLNCT,M16,MOCMNEM
*
*
         LI,2     LNOL-1            #LINES IN SYSTEM -1
         LI,R7    SLVLNCT           GET SLAVE LINE CURRENT TYPE MASK
         LW,SR2   S:CUN             GET CURRENT USER#
         LI,R0    0                 INITIALIZE R0
CLEAR10  EQU      %
         LC       MODE5,2
         BCR,8    CLEAR20           NOT SLAVE, OK
         CB,SR2   LB:UN,2           BELONG TO THIS GUY
         BNE      CLEAR20           NO, OK
         BAL,11   KILLIO            YES, CLEAR TABLES
         WD,0     X'37'             DISABLE
         LB,5     MODE5,2           SET LINE TYPE TO DEFAULT
         LW,6     5
         SLS,6    6
         STS,6    5
         STB,5    MODE5,2
         STB,0    LB:UN,2           SET LINE STATE=FREE
         WD,0     X'27'             ENABLE
CLEAR20  AI,2     -1
         BGEZ     CLEAR10
         LI,R2    DCTSIZ            MAX DCT INDEX
GETMNEM  EQU      %
         LD,R6    DCT16,R2          GET CANNED DEVICE MNEMONIC
         SLD,R6   8                 1ST 2 CHARACTERS NOW IN R6
         AND,R6   M16               ISOLATE THEM
         CI,R6    MOCMNEM           SEE IF IT'S MNEMONIC FOR MOC LN
         BNE      CKINDEX           B, IF NOT & SEE IF WE'RE THROUGH
         LI,R5    2
         LH,SR4   DCT23,R2          GET CNM MOC LINE SWITCHES
         CB,SR2   SR4,R5            SEE IF CURRENT USER OWNS LINE
         BNE      CKINDEX           B, IF HE DOESN'T; NOTHING TO RELEASE
         STB,R0   SR4,R5            SET LINE STATE=FREE
         AI,R5    1                 POINT TO CNM MOC LINE FLAGS
         LB,R6    SR4,R5            GET UM
         SLS,R6   6                 ADJUST DEFAULT BITS
         STS,R6   SR4               SET CURRENT TYPE=DEFAULT
         STH,SR4  DCT23,R2          RESTORE CNM MOC LINE SWITCHES
CKINDEX  EQU      %
         BDR,R2   GETMNEM
         FIN
         PULL     7,R5
         B        T:SELFDESTRUCT
BAAVRFNMT STB,SR4 AVRFNMT,R1
* SIXBACK RETURNS A SIX CHARACTER SERIAL #
* R2=HASHED SERIAL #
* SR1-SR2=EBCDIC SIX CHARACTER SERIAL # LEFT JUSTIFIED
* CALL: BAL,SR4   SIXPACK
*
SIXBACK  EQU      %
         PUSH      4,R3
         SLD,R2   -20
         SLS,R3   -12
         LW,R5    R3
         LI,R6    6
SIXBACK1 EQU      %
         SLD,R2   -2
         SLS,R3   -26
         LI,R4    0
         DW,R4    XA
         OR,R3    R4
         BEZ      %+2
         AI,R3    X'80'
         AI,R3    X'40'
         SLD,SR1  -8
         STB,R3   SR1
         BDR,R6   SIXBACK1
         PULL     4,R3
         B        *SR4
         PAGE
CKF1     RES     0
         LD,D3    DOUBLEZERO
         LW,1     3
         LD,D1    AVRTBL,1
         STH,D3   AVRID,R1
         CW,D2    Y1                SCRATCH
         BANZ     SCRCLR            YES
         STD,D3   AVRTBL,R1
         STW,D1   9,R7              REEL NR
*                                   TYPE OUT
         LI,8     X'1F'             BUFFER SIZE
         ANSNOP   CKF11
         LCF,2    ANSFLGS,1
         BCR,X'C' CKF11             NOT ANS TAPE
         STB,D3   ANSFLGS,R1        CLEAR ANSFLGS
         PUSH     R1                SAVE AVR INDEX
         MI,R1    6*4               AVRFNMT INDEX
         ANLZ,R1  BAAVRFNMT         BYTE ADDRESS AVRFNMT
         OR,R1    Y18               SIX WORD TABE
         MBS,0    BA(X0)            CLEAR
         PULL     R1                RESORE AVR INDEX
         PSW,2    TSTACK
         LW,2     D1                UNHASH ANS SERIAL NO.
         BAL,11   SIXBACK
         PLW,2    TSTACK
         LCI      2
         STM,8    9,7
         LI,8     X'21'
*                 BUFFER SIZE FOR ANS TAPES
CKF11    EQU      %
         LD,D1    DCT16,R2          * NAME OF THAT GUY.
         STB,8    13                BUFFER SIZE
         STW,13   2,7
CKXX     RES      0
         PUSH     7,R1
         BAL,11   MSROCTY           TYPE
         PULL     7,R1
CKJD     RES      0
*           2=DCTX
         BAL,11   DHHIT
         BAZ      CKFF              NO
         BAL,11   RSETSPIN          RESET SPIN BITS
         LB,4     DCT4,2            TYPE
         BAL,15   DEALL             DEALLOCATE O AND G
         B        CKFF              LOOP
SCRCLR  RES   0
         AND,D2   X1000FFFF
         STD,D1   AVRTBL,R1
         B        CKJD              DONT TYPE
CKMESK   DATA     X'FFFFC700'
CKMESS   RES      0
         DATA     X'1FC1F0F0'       #A00
         TEXT     ' DISMOUNT AND SAVE REEL'
         END

