         PCC      0                                                             
         SYSTEM   SIG9P                                                         
         SYSTEM   OPTIONS                                                       
*                                                                               
*        OVERLAY CONTAINS SECONDARY TASK TERMINATION INCLUDING                  
*                 'TT' SUBROUTINES                                              
*                                                                               
         DEF      A:TT              SEC TASK TERMINATION                        
         DEF      TTPRIM                                                        
         DO1      #MAP                                                          
         DEF      FMTCL                                                         
         DEF      TTX                                                           
         DO1      #TJE                                                          
         DEF      TTLN,TTLNX                                                    
OLAYFLAG EQU 'TT'                                                               
         SYSTEM   CPRMON                                                        
         TITLE    '** TT OVERLAY **'                                            
         TITLE    '** TT - OVERLAY EXITS AND REFS **'                           
TTX5R4   PULL     5,R4              PULL AND EXIT                               
         B        *R8                   INTERNAL ONLY                           
TTXR8    PULL     R8                COMMON EXIT ,TT SUBR                        
         B        *R8                                                           
TTX      B        *R8                                                           
         TITLE    '** TT - SECONDARY TASK TERMINATION **'                       
*                                                                               
*        TT       SUBROUTINE TO DO SECONDARY TASK TERMINATION                   
*                 ALL PHASES WHICH DO NOT HAVE TO BE                            
*                 IN RBM ROOT                                                   
*                                                                               
*        REGISTERS AT ENTRY                                                     
*        R4       TASK ID                                                       
*        R5       LMID                                                          
*                                                                               
TT       RES      0                                                             
A:TT     EQU      TT                                                            
         PUSH     R8                SAVE EXIT                                   
*                                   TERMINATION LOGIC                           
         DO1      #ECB                                                          
         BAL,R8   TTRECB            DELETE THE R-ECBS                           
*                                                                               
         BAL,R8   TTSECB            CLEAN UP SECBS                              
*                                                                               
         LI,R0    0                                                             
         LW,R1    XSTIT             ZERO TERM BIT SO THAT FILE DIRECTORY        
         STS,R0   STITCB,R4          UPDATES CAN OCCUR.                         
         DO       #MAP                  SECONDARY MAPPED                        
         BAL,R8   FMTCL                                                         
         ELSE                                                                   
         BAL,R8   TTCLDCB           CLOSE USER DCBS                             
         FIN                                                                    
*                                                                               
         BAL,R8   TTSPCE            RELEASE MISC TSPACE                         
*                                                                               
         BAL,R8   TTCAL             DISCONNECT FROM CAL2,3,4                    
*                                                                               
         PUSH     3,R4              SAVE R4-R6                                  
         DO1      #DEBUG                                                        
         BAL,R8   TTDEBUG           CLEAN UP DEBUG CONTROLS                     
*                                                                               
         BAL,R8   TTBREAK           CLEAN UP BREAK CONTROLS                     
         PULL     3,R4              RESTORE R4-R6                               
*                                                                               
         DO       #MAP                                                          
         BIFREAL  TT01              UNMAPPED, NO SEGMENT CLEANUP                
         BAL,R8   MMTSEC            DO ALL MAPPED TASK CLEANUP                  
         ELSE     #MAP                                                          
         LW,R8    LMIPL,R5          GET PUBLIBS USED                            
TT00     CI,R8    0                 ANY USED                                    
         BE       TT01              NONE OR DONE                                
         LB,R2    R8                GET A LIBRARY INDEX                         
         SLS,R8   8                 SET UP NEXT                                 
         CI,R2    0                 THIS A GOOD ONE                             
         BE       TT00              NO                                          
         LB,R1    LMIUSERS,R2       GWT USE COUNT                               
         BEZ      %+3               IF ZERO DON'T DECREMENT                     
         MTB,-1   LMIUSERS,R2       DECR IT                                     
         BNEZ     TT00              NOT LAST USER                               
         STD,R1   LMINAME,R2        CLEAR LIBRARY NAME                          
         STW,R1   LMIPL,R2          CLEAR LIBRARY USE                           
         STH,R1   LMISTAT,R2        CLEAR USE INDICATOR                         
         B        TT00              DO NEXT ONE                                 
         FIN      #MAP                                                          
*                                                                               
TT01     RES      0                                                             
         DO1      #ECB                                                          
         BAL,R8   TTENQ             RELEASE ALL ENQ'S                           
*                                                                               
         LB,R6    STIJID,R4         TEST FOR AND CLEANUP JOB                    
         BAL,R8   TTJOB                 CONTROL DATA                            
*                                                                               
TT02     EQU      %                                                             
         DO       #MAP                                                          
         BIFREAL  TT03                                                          
         BAL,R8   MMRELS            RELEASE AST,ACI                             
         FIN      #MAP                                                          
*                                                                               
TT03     LW,R1    TDRDLVL           DISABLE DISPATCHER CONTROLLING              
         LW,R2    TDRDLGP               THE TERMINATING TASK                    
         WD,R1    -X'0200',R2                                                   
         PUSH     2,R1              SAVE TRIGGER VALUES                         
         DO       #TJE                                                          
         BAL,R8   TTLN              IS IT A TERMINAL JOB                        
         B        TT03A             NO                                          
         LD,R0    LMINAME,R5        IS IT TEL                                   
         CD,R0    TTTEL                                                         
         BNE      TT03A             NO                                          
         DISABLE                                                                
         PUSH     R4                SAVE TASKID                                 
         LB,R0    DCTTJE,R2         GET FLAGS                                   
         CI,R0    TJEACT            IS IT ACTIVE                                
         BAZ      %+2               NO, DONT INIT                               
         OR,R0    XTJEINIT          SET INIT                                    
         STB,R0   DCTTJE,R2         RESTORE IT                                  
         LW,R1    XSTISTRT                                                      
         LI,R4    TEXTID            GET TEX TASK ID                             
         STS,R1   STIPRIO,R4        START IT                                    
         BAL,R8   TMTRIG            TRIGGER DISP                                
         PULL     R4                                                            
         B        TT04                                                          
*                                                                               
         BOUND    8                                                             
TTTEL    DATA     'TEL ','    '                                                 
*                                                                               
TT03A    EQU      %                                                             
         FIN      #TJE                                                          
         BIFFGD   TT04              FOREGOUND, BYPASS CONTROL                   
         BAL,R11  CTRIG                 TASK TRIGGER FOR JCP                    
         LW,R7    XBIT8                 SET BIT 8 OF K:CTST                     
         STS,R7   K:CTST                                                        
TT04     DISABLE                    SET REGISTERS FOR TTXR8AL                   
         DO       #MULTDSP                                                      
         LW,R6    STIPRIO,R4                                                    
         AND,R6   M8                RDL INDEX                                   
         ELSE     #MULTDSP                                                      
         LI,R6    1                 JUST ONE DISPATCHER                         
         FIN      #MULTDSP                                                      
         LW,R7    STITCB,R4             R4=TASK ID                              
         LW,R12   STCBSTCB,R7           R5=LMID                                 
         AND,R12  M24                   R6=RDLI INDEX                           
         LW,R13   STCBPCB,R7            R12=TCBPOINT FROM STCB                  
         LD,R14   ZEROS                 R13=PCBPOINT FROM STCB                  
*                                       R14,R15=ZEROS                           
         LH,R3    RDLIADD,R6        SET XPSD IN DISP INTERRUPT                  
         LW,R0    TDDISPX               WHICH POINTS TO STCB                    
         STW,R0   0,R3                  TO NEW DISP XPSD                        
*                                                                               
         PULL     2,R1              RESTORE TRIGGER VALUES                      
         PULL     R8                EXIT                                        
         B        TTX                                                           
         DO       #TJE                                                          
TTLN     EQU      %                                                             
         LD,R0    SJI2,R6           GET JOB NAME                                
         SLD,R0   -24               POSITION                                    
         AW,R0    TTNLBB            ADD IN NLBB                                 
         LH,R2    DCT7                                                          
         CD,R0    DCT16,R2          THIS ONE                                    
         BE       %+3               YES                                         
         BDR,R2   %-2                                                           
         B        %+2                                                           
         AI,R8    1                 INCR FOR GOOD                               
TTLNX    B        *R8               EXIT                                        
*                                                                               
TTNLBB   DATA     X'155A5A00'                                                   
         FIN      #TJE                                                          
         TITLE    '** TT - PRIMARY TASK TERMINATION **'                         
*                                                                               
*        TTPRIM   COMPOSITE CALL TO ALL PRIMARY TASK TERMINATION                
*                 SUBROUTINES.  FGL2 BALS TO TTPRIM ONCE TO DO                  
*                 ECB, DCB, ETC. CLEANUP                                        
*        R5       LMI INDEX OF LM BEING TERMINATED                              
*                                                                               
TTPRIM   PUSH     15,R1             SAVE REGISTERS                              
*                                                                               
         LW,R1    XSTIT             SWAP CONTROL TASK TO                        
         LI,R4    CTID                                                          
         LW,R0    LMILWA,R5             BEING TERMINATED                        
         LB,R6    R0                    R6=JID                                  
         DISABLE                                                                
         STS,R1   STITCB,R4             SET 'T' BIT IN STI                      
         LW,R0    LMISDT,R5                                                     
         STB,R4   R0                                                            
         STW,R0   LMISDT,R5                                                     
         STB,R5   STILMID,R4                                                    
         STB,R6   STIJID,R4                                                     
         LI,R8    X'20'             SECONDARY, NOT CPR                          
         STB,R8   PCBPOINT                                                      
         ENABLE                                                                 
*                                                                               
         DO1      #ECB                                                          
         BAL,R8   TTRECB            CLEAN UP R-ECBS                             
*                                                                               
         BAL,R8   TTSECB            CLEAN UP S-ECBS                             
*                                                                               
         PUSH     3,R4              SAVE R4-R6                                  
         DO1      #DEBUG                                                        
         BAL,R8   TTDEBUG           CLEAN UP DEBUG CONTROLS                     
*                                                                               
         BAL,R8   TTBREAK           CLEAN UP BREAK CONTROLS                     
         PULL     3,R4              RESTORE R4-R6                               
*                                                                               
         LI,R0    0                                                             
         LW,R1    XSTIT             ZERO TERM BIT SO THAT FILE DIRECTORY        
         STS,R0   STITCB,R4          UPDATES CAN OCCUR.                         
         BAL,R8   TTCLDCB           GO CLOSE DCBS NOW THAT IO                   
         DO       #MAP                                                          
         BAL,R8   FMTCL             CLEANUP REMAINING (IF ANY) FILES            
         FIN      #MAP                                                          
*                                       QUIESCED                                
         BAL,R8   TTCAL             DISCONNECT FROM CAL2,3,4                    
*                                                                               
         DO1      #ECB                                                          
         BAL,R8   TTENQ             RRELEASE ANY STRAY ENQS                     
*                                                                               
         DO       #MAP                                                          
         LW,R0    LMISDT,R5         DID PRIMARY EVER GET PREF                   
         CW,R0    XLMIPP                PAGES, IF YES, GO                       
         BAZ      TTPRIM1               TO SUBR TO FORCE RELEASE                
         BAL,R8   MMTPRIM                                                       
         FIN      #MAP                                                          
*                                                                               
TTPRIM1  BAL,R8   TTJOB             CLEAN UP JOB IF REQUIRED                    
*                                                                               
         LI,R5    CTLMID                                                        
         LI,R6    RBMJID                                                        
         DISABLE                                                                
         STB,R5   STILMID,R4                                                    
         STB,R6   STIJID,R4                                                     
         LI,R8    X'A0'             SECONDARY, CPR TASK                         
         STB,R8   PCBPOINT                                                      
         ENABLE                                                                 
*                                                                               
         PULL     15,R1             PULL REGISTERS AND EXIT                     
         B        TTX                                                           
         TITLE    '** TT - POST R-ECB SUBROUTINE **'                            
*                                                                               
*                 **********  CLEAN UP R-ECBS  ****************                 
*                                                                               
         DO       #ECB                                                          
TTRECB   PUSH     5,R4              SAVE REGISTERS                              
*                                   R5=LMID                                     
*                                                                               
         LW,R2    LMIRECB,R5        CLEAN-OUT R-ECBS BY POSTING                 
TTRE1    BEZ      TTRE8                 END OF R-ECBS                           
         LW,R7    ECBRECB,R2            R7=NEXT MEMBER IN CHAIN                 
         LW,R6    TYCWTT                R6=TERMINATION CODE                     
         LH,R0    LMISTAT,R5            ABORTING?                               
         CI,R0    LMIA                                                          
         BAZ      TTRE2                 NO                                      
         LW,R6    TYCWTA                CHANGE COMPL WORD                       
TTRE2    LI,R15   0                     R15=TYC FROM POST RTN                   
         DISABLE                    ECB NOT POSTABLE, TRY TO                    
         LW,R0    ECBFPT,R2             RECOVER.  IF IT WAS                     
         CW,R0    XECBDP            IS IT DELETE-ON-POST                        
         BANZ     TTRE6A            YES, BRANCH                                 
         CW,R0    XECBPOST              IN POST WHEN TERM                       
         BAZ      TTRE3                 OCCURED, REVERSE POST                   
         AND,R0   XECBNPST              AND REDO POST                           
         STW,R0   ECBFPT,R2                                                     
TTRE3    RES      0                                                             
         PUSH     R7                SAVE NEXT MEMBER                            
         BAL,R8   EMPOST            POST THE ECB                                
         B        TTRE6                 ERROR, TRY TO KEEP GOING                
         PULL     R7                RESTORE NEXT ECB ID IN CHAIN                
*                                                                               
TTRE4    LB,R5    R7                                                            
         LW,R2    R7                GET NEXT R-ECB                              
         AND,R2   M24                   IF THERE IS ONE                         
         B        TTRE1                                                         
*                                                                               
TTRE6    RES      0                                                             
         PULL     R7                 RESTORE NEXT ECB IN CHAIN                  
         LB,R5    R7                R5= LM I.D.                                 
         LW,R0    ECBSECB,R2            IS IT LINKED?                           
         BNEZ     TTRE7                 YES, LEAVE IT FOR S-TASK                
         BAL,R8   EMDELECB          DELETE THE ECB                              
         NOP                            ERROR                                   
         ENABLE                                                                 
         B        TTRE4             DO NEXT R-ECB                               
*                                                                               
*   PROCESS DELETE-ON-POST ECBS.                                                
*   DP ECBS IN R-CHAIN CAN ONLY BE SIGNAL,INIT,MM                               
TTRE6A   RES      0                                                             
         CW,R0    XECBPOST          IS IT IN POST                               
         BAZ      TTRE3             NO, POST IT                                 
TTRE7    RES      0                                                             
         PUSH     R7                                                            
         DISABLE                                                                
         BAL,R8   EMRRECB           DETACH FROM R-CHAIN                         
         NOP                                                                    
         ENABLE                                                                 
         PULL     R7                                                            
         B        TTRE4                 NO NEXT R-ECB                           
*                                                                               
TTRE8    B        TTX5R4            PULL AND EXIT                               
         FIN      #ECB                                                          
         TITLE    '** TT - CLEANUP S-ECBS SUBROUTINE **'                        
*                                                                               
*                 **********  CLEAN UP R-ECB'S  ***************                 
*                                                                               
TTSECB   PUSH     5,R4              SAVE REGISTERS                              
*                                   R5=LMID                                     
*                                                                               
         DO       #ECB                                                          
TTSE0    LW,R2    LMISECB,R5        REMOVE ANY CHECK BITS                       
         BEZ      TTSEX             NO SECBS IF 0                               
TTSE1    LW,R7    ECBSECB,R2        SET R7- NEXT ECB                            
         DISABLE                                                                
         LW,R0    ECBFPT,R2             R0=FLAGS                                
         AND,R0   XECBNCHK                                                      
         STW,R0   ECBFPT,R2                                                     
         LI,R1    ECBT                  TYPE =0                                 
         LH,R1    *R2,R1                                                        
         BNEZ     TTSE10            B IF NOT TYPE 0                             
         BAL,R8   EMDELECB          DELETE THE ECB                              
         NOP                                                                    
         ENABLE                                                                 
         LW,R2    R7                                                            
         B        TTSE14                                                        
TTSE10   RES      0                                                             
         AND,R0   XECBNDP           SET DP=0                                    
         STW,R0   ECBFPT,R2         STORE ECB WORD 1                            
TTSE13   LW,R2    ECBSECB,R2                                                    
TTSE14   AND,R2   M24                                                           
         BNEZ     TTSE1                                                         
         ENABLE                                                                 
         FIN      #ECB                                                          
         LI,R3    Y4                SET R3=WAITALL FPT (40--0)                  
         BAL,R8   TMWALL                R3=WAITALL FPT                          
         DO       #ECB                                                          
TTSE3    LW,R2    LMISECB,R5            DELETE LEFT OVER SECBS                  
         BEZ      TTSEX                 DONE                                    
         BAL,R8   EMDELECB                                                      
         NOP                            ERROR                                   
         ENABLE                                                                 
         B        TTSE3                                                         
         FIN      #ECB                                                          
TTSEX    ENABLE                                                                 
         B        TTX5R4            PULL AND EXIT                               
         TITLE    '** TT - T-SPACE CHAINED TO STI SUBROUTINE **'                
*                                                                               
*                 **********  CLEAN UP MISCELLANEOUS TSPACE ***                 
*                                                                               
TTSPCE   PUSH     R8                SAVE EXIT                                   
*                                                                               
*                                   R4=TASK ID                                  
TTSP1    LW,R7    STISPCE,R4        ANY STRAY TSPACE?                           
         BEZ      TTXR8                 NO                                      
         LW,R0    0,R7                  YES, LINK NEXT CHAINED                  
         STW,R0   STISPCE,R4            SPACE TO THE TASK AND                   
         BAL,R8   RELTEMP               RELEASE THIS ONE                        
         B        TTSP1                                                         
         TITLE    '** TT - DISCONNECT FROM CAL2,3,4 SUBROUTINE **'              
*                                                                               
*                 **********  DISCONNECT CAL2,3,4 **********                    
*                                                                               
TTCAL    LH,R0    LMISTAT,R5        FETCH CAL INDICATORS                        
         LI,R1    X'49'                                                         
         LW,R2    X'41'                 UNIMPL INSTR TRAP XPSD                  
         DISABLE                    DISCONNECT ONE AT A TIME                    
TTCAL1   CW,R0    CALFLAG-X'49',R1                                              
         BAZ      TTCAL2                                                        
         STW,R2   0,R1                                                          
         EOR,R0   CALFLAG-X'49',R1                                              
TTCAL2   AI,R1    1                                                             
         CI,R1    X'4C'             DONE                                        
         BL       TTCAL1                NO                                      
         STH,R0   LMISTAT,R5            YES, STORE FLAGS                        
         ENABLE                                                                 
         B        *R8               EXIT                                        
         TITLE    '** TT - ENQ CONTROLS SUBROUTINE **'                          
*                                                                               
*                 **********  CLEAN UP ENQUEUES **************                  
*                                                                               
         DO       #ECB                                                          
TTENQ    PUSH     5,R4                                                          
*                                                                               
         LW,R1    LMIAET,R5         FETCH TASK LEVEL AET                        
         BEZ      TTENQ3                NONE                                    
         LW,R6    SJI1,R6           R6=JCB FOR ENQ SUBR                         
TTENQ1   LW,R7    AETEDT,R1         USED?                                       
         BEZ      TTENQ2                NO                                      
         LW,R9    R7                SET FLAGS FOR DEQ AT TASK LEVEL             
         BAL,R8   TMDELAET          REMOVE THE ENQ                              
TTENQ2   AI,R1    AETSIZE           ADVANCE TO NEXT AET                         
         MTB,-2   R1                    DECR COUNT                              
         BNEZ     TTENQ1            CONTINUE                                    
*                                                                               
         LW,R7    LMIAET,R5         RELEASE THE AET SPACE                       
         BAL,R8   RELTEMP                                                       
TTENQ3   B        TTX5R4            PULL AND EXIT                               
         FIN      #ECB                                                          
         TITLE    '** TT - FMTCL ROUTINE **'                                    
*************                                                                   
*   FMTCL   *                                                                   
*************                                                                   
*                                                                               
*   ROUTINE CLEANS UP RFT ENTRIES FOR THE SPECIFIED LOAD MODULE                 
*                                                                               
*   AT ENTRY:     R8   LINK                                                     
*                 R5   LMI INDEX                                                
*   ROUTINE ALWAYS RETURNS +1                                                   
*   ROUTINE SAVES R4-R6                                                         
*                                                                               
         DO       #MAP                                                          
FMTCL    RES      0                                                             
         PUSH     5,R4              SAVE REGISTERS                              
         LW,R4    LMIRFT,R5         ADDR OF TABLE FOR THIS LM                   
         BEZ      FMTCEXIT          EXIT, TABLE NONEXISTENT                     
         LH,R7    RFT#              GET NUMBER OF RFT ENTRIES TO SCAN           
*                                    ACTIVITY TABLE.                            
FMTCL1   LB,R0    *R4,R7            R0=NO OF DCBS OPEN TO THIS FILE             
         BEZ      FMTCL3            NONE, GET NEXT                              
         DISABLE                                                                
         LD,R14   RFT1,R7           TEST IF FILE ENTRY IS IN USE                
         BEZ      FMTCL3            BRANCH IF NOT                               
         DO       #SYMB                                                         
         CW,R7    SM:C              IS THIS A SYMBIONT C FILE                   
         BE       FMTCL3            YES, DON'T CLOSE IT                         
         LB,R1    RFT8,R7           GET AREA INDEX                              
         LH,R15   MDNAME,R1                                                     
         AND,R15  M16               MASK, R15= AREA NAME                        
         CI,R15   KIS               IS IT THE IS AREA                           
         BE       FMTCL3            YES, DON'T CLOSE IT                         
         CI,R15   KOS               IS IT THE OS AREA                           
         BE       FMTCL3            YES, DON'T CLOSE IT                         
         FIN      #SYMB                                                         
         LB,R15   RFT13,R7          TOTAL DCBS OPEN IN THE JOB                  
         SW,R15   R0                SUBTRACT TOTAL DCBS OPEN IN LM              
         AI,R15   1                 CLOSRFIL DECREMEMTS BY 1                    
         BLEZ     FMTCL3            B IF COUNT BAD                              
         STB,R15  RFT13,R7          STORE NEW COUNT                             
         BIFFGD   FMTCL2            B IF FGD                                    
         LB,R15   RFT15,R7          TOTAL DCBS OPEN IN BKGD JOB                 
         SW,R15   R0                                                            
         AI,R15   1                                                             
         BLEZ     FMTCL3            B IF COUNT BAD                              
         STB,R15  RFT15,R7          STORE NEW BKGD COUNT                        
FMTCL2   ENABLE                                                                 
         LI,R1    -1                R1=PHALSE FPT CODE FOR FINDDIR              
         PUSH     4,R4              SAVE R4-R7                                  
         BAL,R5   CLOSRFIL          GO CLOSE THE FILE                           
         NOP      0                                                             
         PULL     4,R4              RESTORE REGISTERS                           
FMTCL3   BDR,R7   FMTCL1            LOOP BACK FOR NEXT ENTRY                    
         LW,R7    R4                TSPACE CONTROL WORD                         
         BAL,R8   RELTEMP           RELEASE TSPACE                              
         LI,R0    0                                                             
         STW,R0   LMIRFT,R5         ZERO POINTER TO TABLE                       
FMTCEXIT RES      0                                                             
         PULL     5,R4                                                          
         B        TTX               B *R8                                       
*                                                                               
*                                                                               
         FIN      #MAP                                                          
         TITLE    '** TT - TTCLDCB (CLOSE DCBS) **'                             
***************                                                                 
*   TTCLDCB   *                                                                 
***************                                                                 
*                                                                               
*   ROUTINE CLOSES DCBS IN THE USER'S DCBTAB                                    
*                                                                               
*   AT ENTRY:     R8    LINK                                                    
*                 R4 TASK ID (TERMINATING TASK)                                 
*   ROUTINE ALWAYS RETURNS +1                                                   
*   ROUTINE SAVES R4-R8                                                         
*                                                                               
TTCLDCB  RES      0                                                             
         PUSH     5,R4                                                          
         LB,R5    STILMID,R4        GET LOAD MODULE INDEX                       
         LW,R9    LMIPCB,R5         GET PCB POINTER                             
         AI,R9    PCBDCBTB          DCBTAB ADDRESS ADDRESS                      
         BAL,R8   TMVADR            VERIFY ADDRESS AS ACCESIBLE                 
         B        TTX5R4            PULL AND EXIT IF BAD ADDR                   
         LW,R9    *R9               DCBTAB ADDRESS                              
         BEZ      TTX5R4            PULL AND EXIT IF NO DCBTAB                  
         BAL,R8   TMVADR                                                        
         B        TTX5R4            PULL AND EXIT IF BUM ADDR                   
         LW,R1    *R9               GET DCBTAB COUNTER                          
         BEZ      TTX5R4            PULL AND EXIT IF EMPTY                      
TTCDCB1  RES      0                                                             
         AI,R9    3                                                             
         BAL,R8   TMVADR                                                        
         B        TTX5R4            PULL AND EXIT IF BUM ADDR                   
         LW,R4    *R9               GET DCB ADDRESS                             
         XW,R4    R9                                                            
         LB,R10   *R9               GET DCB LENGTH                              
         AW,R10   R9                DCB LWA                                     
         LI,R11   0                 REQUIRE WRITABLE                            
         BAL,R8   TMCKADP           CHECK ADDRESS PAIR                          
         B        TTX5R4            GIVE UP IF NOT WRITABLE                     
         XW,R4    R9                                                            
         LW,R0    0,R4              WORD 0 OF DCB                               
         CW,R0    Y002              IS IT OPEN                                  
         BAZ      TTCDCB2           NO, DON'T CLOSE IT                          
*   BUILD FPT FOR CLOSE IN R4-R7                                                
         LI,R0    X'15'             FPT CODE                                    
         STB,R0   R4                FPT WORD 0                                  
         LW,R5    YC                FPT WORD 1                                  
         LI,R6    TTX5R4            FPT WORD 2 (ERR EXIT)                       
         LI,R7    TTX5R4            FPT WORD 3 (ABN EXIT)                       
         STW,R6   3,R4              STORE ERR ADDR IN DCB                       
         STW,R6   4,R4                                                          
         CAL1,1   R4                CLOSE THE DCB                               
TTCDCB2  BDR,R1   TTCDCB1           GET NEXT DCB                                
         B        TTX5R4            PULL AND EXIT                               
         TITLE    '** TT - CLEAN UP BREAK CONTROLS **'                          
*                                                                               
*                                                                               
*        TTBREAK  SUBR TO CLEAN UP BREAK CONTROLS                               
*                                                                               
*                 ENTRY  R4=TID                                                 
*                        R5=LMID                                                
*                                                                               
*                        BAL,R8    TTBREAK                                      
*                 EXIT  +1                                                      
*                                                                               
*                                                                               
TTBREAK  EQU      %                                                             
         LB,R6    STIJID,R4         JID                                         
         LW,R6    SJI1,R6           JCB ADDRESS                                 
         LW,R0    JCBREAK,R6        BREAK CONTROL WORD                          
         BEZ      *R8               B IF NO BREAK CONTROL                       
         LB,R1    R0                GET TASK ID                                 
         LB,R1    STILMID,R1        LMID OF BREAK RECEIVER TASK                 
         CW,R1    R5                IS THIS THE LOAD MODULE                     
         BNE      *R8               B IF NO                                     
         LI,R0    0                                                             
         STW,R0   JCBREAK,R6        CLEAR BREAK CONTROLS                        
         B        *R8                                                           
*                                                                               
         OLAYEND                                                                
*                                                                               
         END                                                                    
