         SYSTEM   SIG9P                                                         
         SYSTEM   OPTIONS                                                       
*                                                                               
*                                                                               
*                                                                               
        DO       #MAP                                                           
*                                                                               
*                                                                               
         DEF      A:PLO1                                                        
         DEF      PLO1EXIT                                                      
                  DEF      PUBLIB                                               
PLO1     EQU      %                                                             
A:PLO1   EQU      PLO1                                                          
OLAYFLAG EQU      'PLO1'                                                        
         SYSTEM   CPRMON                                                        
         TITLE    'PROCESS PUBLIC LIBRARIES '                                   
*                                                                               
*        PUBLIB   PROCESSES ALL SECONDARY PUB LIBS                              
*                                                                               
*                 AT ENTRY:                                                     
*                             R8 =LINK                                          
*                             R14=ADDRESS OF CONTEXT PAGE                       
*                             R13=ADDRESS OF PUBLIB AREA IN LM HEADER           
*                                                                               
*                 AT EXIT:                                                      
*                             R13=DESTROYED                                     
*                                                                               
*                             RETURNS TO LINK +1 IF LIBRARIES LOADED            
*                                   SUCCESSFULLY                                
*                                                                               
*                             RETURNS TO LINK IF ERROR - R15 HAS TYC            
*                                                                               
*                                                                               
PUBLIB   EQU      %                                                             
         PUSH     13,R0             SAVE REGS                                   
         LI,R1    0                 LOOP COUNT FOR MAX PUBLIBS                  
PL0100   LCI      2                 SET FOR TWO REGS                            
         LM,R10   *R13              GET PUBLIB NAME                             
         CD,R10   ZEROS             CHECK IF NAME PRESENT                       
         BNEZ     PL0102            B IF NAME PRESENT                           
PL0101   EQU      %                                                             
         PULL     13,R0             RESTORE REGS                                
         AI,R8    1                 TAKE NORMAL EXIT                            
PLO1EXIT B        *R8               RETURN TO USER                              
*                                                                               
PL0102   EQU      %                                                             
         BAL,R8   PUBFIND           SEE IF LIBRARY IS ALREADY IN                
         B        PL0110            B IF NOT FOUND                              
         LW,R9    LMISDT,R7         GET SD ADDRESS                              
         LI,R6    SDTUSING          OFFSET TO TASKS USING                       
         MTB,1    *R9,R6            INCREMENT TASKS USING COUNT                 
         ENABLE                                                                 
         AND,R9   M24               MASK ADDRESS                                
         BAL,R8   TISAST            SET AST                                     
         B        PUBX              ERROR TYCB3                                 
         LI,R6    SDSEGNUM          OFFSET TO SEGMENT NUMBER                    
         LH,R2    *R9,R6            GET SEGMENT NUMBER                          
         AND,R2   M16               MASK FOR SIGN EXTESION                      
         LI,R6    TISCTX3           USE CONTEXT AREA 3                          
         LW,R6    *R14,R6           GET ADDRESS OF CONTEXT AREA                 
         LCI      3                 SET FOR THREE WORDS                         
         LM,R3    PLAFPT            GET PROTOTYPE ACTIVATE FPT                  
         OR,R3    R2                SET SEGMENT NUMBER                          
         LCI      3                 SET FOR THREE WORDS                         
         STM,R3   *R6               PLACE IN CONTEXT AREA                       
         CAL1,7   *R6               ACTIVATE THE PUBLIB SEG TO THIS TAS         
         AI,R6    TISATYC           OFFSET TO ACTIVATE TYC                      
         LB,R15   *R6               GET TYC                                     
         CI,R15   TYCNORM           IS IT NORMAL                                
         BNE      PUBX              B IF NO                                     
PL0103   EQU      %                                                             
         LW,R2    LMIFWA,R7         GET FWA OF CONTEXT SEGMENT                  
         BEZ      PL0105            B IF NO CONTEXT SEGMENT                     
         LI,R6    TISCTX3           USE CONTEXT AREA 3                          
         LW,R9    *R14,R6           GET ADDRESS OF CONTEXT AREA                 
         LI,R6    OVVMWO            OFFSET TO VM WO                             
         STW,R2   *R9,R6            SET WORD ORIGIN IN FAKE OVLOAD TABL         
         LW,R3    PLCTXSEG          PROTO TYPE OVLOAD FIRST WORD                
         LB,R2    R2                GET # OF PAGES                              
         LI,R4    1                 BYTE OFFSET                                 
         STB,R2   R3,R4             SET IN OVLOAD PROTOTYPE                     
         MTW,1    PLSEG#            NEXT SEG NUMBER                             
         LW,R0    PLSEG#                                                        
         AND,R0   M12               MASK                                        
         OR,R3    R0                SET SEG # = TO LOOP COUNT                   
         STW,R3   *R9               SET IN FAKE OVLOAD TABLE                    
         BAL,R8   TISD              CONSTRUCT A SEGMENT DESCRIPTOR              
         B        PUBX              B IF NO SPACE OR FWA LIMIT                  
         BAL,R8   TISAST            SET AST ENTRY                               
         B        PUBX              ERROR CANNOT SET AST ENTRY                  
         ENABLE                                                                 
         LCI      3                 SET FOR 3 WORDS                             
         LM,R4    PLAFPT            GET PROTOTYPE ACTIVATE FPT                  
         AND,R3   M16               MASK SEGMENT NUMBER                         
         OR,R4    R3                SET SEG # IN FPT                            
         LI,R3    TISCTX3           OFFSET TO CONTEXT AREA 3                    
         LW,R9    *R14,R3           GET ADDRESS OF CONTEXT AREA 3               
         LCI      3                 SET FOR THREE WORDS                         
         STM,R4   *R9               SET IN CONTEXT AREA                         
         CAL1,7   *R9               ACTIVATE TO GET MEMORY                      
         AI,R9    TISATYC           OFFSET TO ACTIVATE TYC                      
         LB,R15   *R9               GET ACTIVATE TYC                            
         CI,R15   TYCNORM           CHECK FOR NORMAL COMPLETION                 
         BNE      PUBX              B IF ERROR                                  
PL0104   EQU      %                                                             
         LW,R0    LMICTXT,R7        GET CONTEXT SEG BYTE COUNT                  
         AND,R0   M16               MASK BYTE COUNT                             
         BEZ      PL0105            B IF CONTEXT SEG NEED NOT BE INITIA         
         LI,R6    TISCTX2           USE CONTEXT AREA 2 TO READ CONTEXT          
         LW,R9    *R14,R6           GET ADDRESS OF CONTEXT AREA TWO             
         LCI      5                 5 WORDS                                     
         LM,R2    PLDCB             GET DCB PROTO TYPE                          
         STM,R2   *R9               STORE IN CONTEXT AREA                       
         LD,R10   LMINAME,R7        GET PUBLIB NAME                             
         LI,R6    5                 OFFSET TO NAME IN DCB                       
         LCI      2                 TWO WORDS                                   
         STM,R10  *R9,R6            STORE FILE NAME IN DCB                      
         AI,R6    2                 MOVE INDEX TO FPT AREA                      
         LW,R8    R1                SAVE R1                                     
         LCI      6                                                             
         LM,R0    PLRFPT            GET READ FPT                                
         AW,R0    R9                SET DCB ADDRESS                             
         LCI      6                                                             
         STM,R0   *R9,R6            STORE FPT IN CONTEXT AREA                   
         AI,R9    7                 POINT TO FPT                                
         LW,R1    R8                RESTORE R1                                  
         LW,R10   LMIFWA,R7         GET BUFFER ADDRESS                          
         AND,R10  M24               MASK                                        
         LW,R12   LMICTXT,R7        GET BYTE COUNT                              
         LH,R11   R12               GET GRANULE DISPLACMENT                     
         AND,R12  M16               MASK                                        
         AND,R11  M16               MASK                                        
         BAL,R8   TISREAD           READ IN CONTEXT                             
         B        PUBXCL2           ERROR IN READING                            
         AI,R9    -7                POINT TO DCB                                
         AND,R9   M24               MASK                                        
         OR,R9    Y15               CLOSE FPT CODE                              
         LW,R10   YC                P1,P2 PRESENCE INDICATORS                   
         LI,R11   PL0107            ERROR ADDRESS                               
         LI,R12   PL0107            ABNORMAL ADDRESS                            
         CAL1,1   R9                CLOSE DCB                                   
PL0105   EQU      %                                                             
         AI,R1    1                 MOVE TO NEXT PUBLIB                         
         AI,R13   2                 STEP POINTER TO NEXT PUBLIB NAME            
         CI,R1    MAXPUBS           MORE THAN MAXIMUM ALLOWED                   
         BL       PL0100            B IF NO                                     
         B        PL0101            B WHEN DONE                                 
*                                                                               
PL0107   EQU      %                                                             
         LB,R15   R10               HERE IF CLOSE ERRORS -GET TYC CODE          
         B        PUBX                                                          
*                                                                               
PL0110   EQU      %                                                             
         LI,R9    PL0111            SET ERROR EXIT ADD. FOR ENQ                 
         LCI      5                 SET FOR 5 WORD FPT                          
         LM,R2    PLENQ             FPT IN REGISTERS                            
         CAL1,7   R2                ENQUEUE ON S:PUBLIB                         
         BAL,R8   PUBFIND           SEE IF FUBLIB IS IN                         
         B        PL0112            B IF NOT FOUND                              
         ENABLE                                                                 
         LI,R9    PL0111            SET ERROR EXIT ADD. FOR DEQ                 
         LCI      5                 SET FOR 5 WORD FPT                          
         LM,R2    PLDEQ             FPT IS IN REGISTERS                         
         CAL1,7   R2                DEQUEUE ON S:PUBLIB                         
         B        PL0102            B TO LINK TO PUBLIB                         
*                                                                               
PL0111   EQU      %                                                             
         B        PUBX                                                          
*                                                                               
PL0112   EQU      %                                                             
         LW,R0    R7                SAVE R7                                     
         LI,R2    TISCTX1           USE CONTEXT AREA 1                          
         LW,R12   *R14,R2           GET ADDRESS OF CONTEXT AREA                 
         LCI      5                 5 WORDS                                     
         LM,R5    PLDCB             GET FIRST FIVE WORDS OF DCB                 
         LCI      7                 LAST 2 WORDS ARE IN R10 R11                 
         STM,R5   *R12              PLACE IN CONTEXT AREA                       
         LI,R2    7                 INDEX FOR FPT                               
         LCI      5                 5 WORDS                                     
         LM,R5    PLRFPT            READ FPT                                    
         AW,R5    R12               SET DCB ADDRESS                             
         LCI      5                 5 WORDS                                     
         STM,R5   *R12,R2           PLACE IN FPT                                
         LW,R9    R12                                                           
         AI,R9    7                 POINTS TO FPT                               
         LW,R7    R0                RESTORE R7                                  
         LI,R2    PLCTX1            PUB LIB CONTEXT AREA ONE                    
         AW,R2    R1                BUMP BY CURRENT PUB LIB #                   
         LW,R10   *R14,R2           GET ADDRESS OF WHERE TO READ HEADER         
         LI,R11   0                 ALWAYS START AT GRANULE ZERO                
         LI,R12   64                ALWAYS READ 16 WORDS                        
         BAL,R8   TISREAD           READ HEADER                                 
         B        PUBXDQCL          B IF ERROR                                  
         LB,R0    *R10              GET FLAG BYTE FROM HEADER                   
         CI,R0    LML               IS IT A PUBLIB                              
         BAZ      PL0114            B IF NOT PUBLIB                             
         CI,R0    LMP10             IS IT FOR PRIMARIES                         
         BANZ     PL0115            B IF YES                                    
         PUSH     R9                SAVE  POINTER  TO  READ FPT                 
         PUSH     R9                SAVE AGAIN FOR LATER                        
         LI,R2    TISCTX2           USE CONTEXT AREA 2                          
         LW,R12   *R14,R2           GET ADDRESS OF CONTEXT AREA TWO             
         MTW,1    PLSEG#            GET NEXT  PUB LIB SEG #                     
         LW,R8    PLSEG#                                                        
         AND,R8   M12               MASK                                        
         AI,R8    X'A000'           SET PUB-LIB IDENTIFICATION                  
         LI,R6    PLVMWO            OFFSET TO FWA                               
         LW,R0    *R10,R6           GET  PUB LIB  FWA                           
         LI,R6    OVVMWO            OFFSET TO  VMWO                             
         STW,R0   *R12,R6           SET WORD  ORIGIN IN FAKE OVLOAD             
         LI,R6    PLVMBL            GET MEMORY BYTE LENGTH                      
         LW,R6    *R10,R6           GET MEMORY BYTE LENGTH                      
         AI,R6    2047              ROUND UP                                    
         SLS,R6   -11               MAKE INTO PAGE LENGTH                       
         LI,R2    1                 BYTE INDEX                                  
         STB,R6   R8,R2             SET VMPL IN  8                              
         LI,R2    PLOVFLG           PUB LIB  FLAGS                              
         STB,R2   R8                SET FLAGS                                   
         STW,R8   *R12              SET IN FAKE  OVLOAD TABLE ENTRY             
         LW,R9    R12               POINT TO FAKE OVLOAD TABLE                  
         BAL,R8   TISD              CONSTRUCT  SEGMENT DESCRIPTOR               
         B        PUBXDQCL          ERROR                                       
         BAL,R8   TISAST            SET AST ENTRY                               
         B        PUBX              ERROR TYCB3                                 
         ENABLE                                                                 
         PULL     R4                GET SAVED  R9                               
         PUSH     R9                SAVE SD ADDRESS                             
         LW,R9    R4                RESTORE FPT ADDRESS                         
         LW,R8    *R12              GET  FIRST WORD OF FAKE  OVLOAD             
         AND,R8   M16               GIVES  SEGMENT NUMBER                       
         LCI      3                 FOR  3 WORDS                                
         LM,R3    PLAFPT            PROTOTYPE  ACTIVATE  FPT                    
         OR,R3    R8                SET SEGMENT NUMBER                          
         LCI      3                                                             
         STM,R3   *R12              USE CONTEXT  AREA TWO                       
         CAL1,7   *R12              ACTIVATE TO GET REAL MEMORY                 
         AI,R12   TISATYC           OFFSET TO TYC                               
         LB,R15   *R12              GET  TYC                                    
         CI,R15   TYCNORM           IS FT NORMAL COMPLETION                     
         BNE      PUBXDQCL          B IF NO                                     
         LI,R2    PLCTX1            PUBLIB CONTEXT AREA ONE                     
         AW,R2    R1                MOVE BY  CURRENT PUBLIB                     
         LW,R2    *R14,R2           GET ADDRESS  OF HEADER                      
         LW,R10   PLVMWO,R2         GET PUB LIB FWA                             
         LI,R11   1                 ALWAYS START AT GRANULE 1                   
         LW,R12   PLLMBL,R2         GET  LOAD MODULE BYTE LENGTH                
         BAL,R8   TISREAD           READ  IN  PUBLIB                            
         B        PUBXDQCL          ERROR                                       
         LCI      2                 SET  FOR TWO  WORDS                         
         LM,R10   *R13              GET NAME  OF PUBLIB                         
         PUSH     R1                SAVE R1                                     
         LI,R1    PLMISTAT          SEC,PUBLIB,LOADED                           
         LW,R6    PLCXVMBL,R2       GET VMBL FOR CONTEXT SEGMENT                
         AI,R6    2047              ROUND UP                                    
         SLS,R6   -11               YEILDS NUMBER OF PAGES                      
         BAL,R8   TMGETLMI          GET LMI ENTRY FOR THIS PUBLIB               
         B        PUBXDQCL          B IF NO LMISPACE                            
         PULL     R1                                                            
         LW,R10   PLCXVMWO,R2       GET CONTEXT SEGMENT WORD ORIGIN             
         AND,R10  M24               MASK                                        
         STB,R6   R10               SET  # OF PAGES                             
         STW,R10  LMIFWA,R5         SET IN LMI                                  
         LW,R6    PLCXVMBL,R2       GET VMBL FOR CONTEXT SEGMENT                
         AI,R6    3                 ROUND UP                                    
         SLS,R6   -2                YEILDS  NUMBER  OF WORDS                    
         AW,R10   R6                YEILDS LAST WORD  ADDRESS                   
         AND,R10  M24               MASK                                        
         STW,R10  LMILWA,R5         SET IN  LMI                                 
         LW,R10   PLCXLMBL,R2       GET LMBL                                    
         AND,R10  M16               MASK                                        
         LW,R6    PLCXLMGO,R2       GET LMGO                                    
         STH,R6   R10               KEICDS LMICTXT ENTRY                        
         STW,R10  LMICTXT,R5        SET IN LMI                                  
         PULL     R10               SAVED  SD ADDRESS                           
         LI,R2    SDLMID            STORE INTO SD                               
         STB,R5   *R10,R2           LMID FIELD FOR TASK TERM                    
         STW,R10  LMISDT,R5         SET IN  LMI                                 
         ENABLE                                                                 
         PULL     R9                                                            
         LW,R9    *R9               GET ADDRESS OF DCB                          
         LI,R8    X'15'             CLOSE FPT  CODE                             
         STB,R8   R9                                                            
         LW,R10   YC                P1 AND P2  PRESENCE BITS                    
         LI,R11   PL0115            ERROR ADDRESS                               
         LI,R12   PL0115            ABNORMAL ADDRESS                            
         CAL1,1   R9                CLOSE DCB                                   
         LI,R9    PL0113            SET EROR ADD. FOR DEQ                       
         LW,R7    R5                                                            
         LCI      5                 SET FOR 5 WORD FPT                          
         LM,R2    PLDEQ             FPT IS IN REGISTERS                         
         CAL1,7   R2                DEQUEUE S:PUBLIB                            
         B        PL0103            B TO DO  CONTEXT SEG                        
*                                                                               
PL0113   EQU      %                                                             
         B        PUBX                                                          
PL0114   EQU      %                                                             
         LI,R15   TYCB4                                                         
         B        PUBXDQCL                                                      
PL0115   EQU      %                                                             
         LI,R15   TYCB5                                                         
         B        PUBXDQCL                                                      
*                                                                               
PUBXCL2  RES      0                                                             
         LI,R3    TISCTX2           CONTEXT AREA CONTAINING FPT                 
         B        PUBXCLOS          B TO CLOSE DCB USED                         
PUBXDQCL EQU      %                                                             
         LI,R9    PUBXCL            SET ERROR EXIT                              
         LCI      5                 SET FOR 5 WORD FPT                          
         LM,R2    PLDEQ             FPT IS IN REGISTERS                         
         CAL1,7   R2                DEQUEUE S:PUBLIB                            
PUBXCL   EQU      %                                                             
         LI,R3    TISCTX1           OFFSET TO CONTEXT AREA 1                    
PUBXCLOS RES      0                                                             
         LW,R9    *R14,R3           GET ADDRESS OF DCB                          
         AND,R9   M24               MASK                                        
         AW,R9    Y15               CLOSE FPT CODE                              
         LW,R10   YC                P1,P2 PRESENCE INDICATORS                   
         LI,R11   PUBX                                                          
         LI,R12   PUBX              SET ERROR AND ABNORM ADD.                   
         CAL1,1   R9                CLOSE DBC                                   
PUBX     EQU      %                                                             
         ENABLE                                                                 
         PULL     13,R0             RESTORE REGS                                
         B        PLO1EXIT          ERROR RETURN                                
*                                                                               
PUBXDQ   EQU      %                                                             
         LI,R9    PUBX                                                          
         LCI      5                 SET FOR 5 WORD FPT                          
         LM,R2    PLDEQ             FPT IN REGISTERS                            
         CAL1,7   R2                DEQUEUE S:PUBLIB                            
         B        PUBX                                                          
*                                                                               
PLQUERR  EQU      %                                                             
         LB,R15   R10               GET ERROR CODE                              
         B        *R9               GO TO APPROPRIATE PLACE                     
*                                                                               
PLCTXSEG DATA     X'A000'           PUBLIB CONTEXT SEGMENT PROTOTYPE            
PLDCB    DATA     X'07000001'                                                   
         DATA     X'03000100'       FP AREA                                     
         DATA     0,0,0,0,0                                                     
PLRFPT   DATA     X'10000000'       FILL IN DCB ADDRESS                         
         DATA     X'31400011'       P3,P4,P8,P10,F7,F3                          
         DATA     0                 BUFFER ADDRESS                              
         DATA     0                 BYTE COUNT                                  
         DATA     0                 KEY                                         
         DATA     0                 TYPE COMPLETION                             
PLENQ    EQU      %                                                             
         DATA     X'4C800000'                                                   
         DATA     P1+P3+P4+F1+F3+F7                                             
         DATA     PLQUERR                                                       
         TEXT     'S:PUBLIB'                                                    
*                                                                               
PLDEQ    EQU      %                                                             
         DATA     X'4D800000'                                                   
         DATA     P1+P3+P4+F7                                                   
         DATA     PLQUERR                                                       
         TEXT     'S:PUBLIB'                                                    
PLAFPT   EQU      %                                                             
         DATA     X'52800000'                                                   
         DATA     X'00400001'                                                   
         DATA     0                                                             
*                                                                               
         TITLE    'FIND PUBLIC LIBRARY'                                         
*                                                                               
*        PUBFIND  SEARCHES  LMI FOR MATCH ON PUBLIB NAME                        
*                                                                               
*                 PT ENTRY:                                                     
*                             R8 =LINK                                          
*                             R10=FIRST WORD OFNAME                             
*                             R11=SECOND WORD OF NAME                           
*                 AT EXIT:                                                      
*                             R7 =LMI INDEX IF FOUND                            
*                                                                               
*                                                                               
*                             RETURNS TO LINK IF ENTRY NOT FOUND                
*                                                                               
*                             RETURNS TO LINK+1 IF ENTRY FOUND                  
*                                   RETURNS DISABLED                            
*                                                                               
*                                                                               
*                                                                               
PUBFIND  EQU      %                                                             
         LB,R7    LMIMAXR           GET NUMBER OF LMI ENTRIES                   
         DISABLE                                                                
PL0201   EQU      %                                                             
         CD,R10   LMINAME,R7        IS THIS ENTRY THE PUBLIB                    
         BE       PL0202            B IF YES                                    
         BDR,R7   PL0201            B FOR NEXT ENTRY                            
         ENABLE                     NOT FOUND EXITS  ENABLED                    
         B        *R8               NOT FOUND EXIT                              
*                                                                               
PL0202   EQU      %                                                             
         AI,R8    1                 FOUND EXIT                                  
         B        *R8               EXITS DISABLED                              
         TITLE    'TASK MGMT SUBR-GET AN LMI ENTRY-TMGETLMI'                    
*******************                                                             
*     TMGETLMI    *                 SUBROUTINE TO AQUIRE AN LMI                 
*******************                 ENTRY                                       
*                                                                               
* ENTRY  R1       STATUS HALFWORD FOR LMISTAT                                   
*        R6       JOB ID                                                        
*        R10-R11  TASK NAME                                                     
*        BAL,R8   TMGETLMI                                                      
*        +1       ERROR EXIT, R15=ERROR CODE                                    
*                             R0=RUN CAL VERSION OF ERROR CODE                  
*                             R5=LMI INDEX IF A DUPLICATE FOUND                 
*                             R9=RUN99 VALUE AT ENTRY                           
*                             ENABLED                                           
*        +2       NORMAL EXIT, R5=LMI INDEX                                     
*                              DISABLED                                         
* REGISTERS USED: R0,R1,R5,R8,R9,R15 IF ERRORS                                  
*          SAVED: R2-R4,R6-R7,R10-R14,R15 IF NO ERRORS                          
* STACK WORDS: NONE                                                             
* SUBROUTINES: NONE                                                             
* NOTES: RUN99 RE-ENTRANCY COUNT USED TO DETECT CONFLICTS WITH                  
*        HIGHER PRIORITY TASKS UPDATING LMI.                                    
*                                                                               
TMGETL0  ENABLE                     ENTER ENABLED MODE                          
TMGETLMI AND,R8   M24               SET R8,BYTE 0=0 (FREE LMI)                  
         LW,R9    RUN99             GET RE-ENTRANCY COUNT                       
         LB,R5    LMI#                  R5=LMI SEARCHING REG                    
TMGETL1  LH,R0    LMISTAT,R5        IS THE ENTRY USED?                          
         BEZ      TMGETL3               NO                                      
         CI,R0    LMIT              IS THE ENTRY SCHEDULED FOR                  
         BANZ     TMGETL4               RELEASE, IGNORE IF YES                  
         CD,R10   LMINAME,R5        IS THE TASK NAME EQUAL TO                   
         BNE      TMGETL4               THE NEW ONE BEING ADDED?                
         LW,R0    LMIJID,R5         IS THE JOB ALSO EQUAL?                      
         CB,R6    R0                                                            
         BNE      TMGETL4               NO                                      
*                                                                               
         LI,R15   TYC62             SET R15 TO ILLEGAL TASK TYC                 
         LH,R0    LMISTAT,R5        IS THE LOAD MODULE PRIMARY                  
         CI,R0    LMISEC                IF NOT, EXIT                            
         B        *R8                   DUPLICATE ENTRY                         
         CI,R0    LMILOAD           IS THE PRIMARY TASK WAITING                 
         BANZ     TMGETL2               FOR INITIATION                          
         LI,R0    3                     R0=RUN CAL ERROR CODES,                 
         B        *R8                    3=PROGRAM RUNNING                      
TMGETL2  LI,R0    4                     R0=RUN CAL ERROR CODES,                 
         B        *R8                   4=PROGRAM WAITING TO LOAD               
*                                                                               
TMGETL3  STB,R5   R8                SAVE FREE ENTRY LOCATION                    
TMGETL4  BDR,R5   TMGETL1           CONTINUE SEARCHING                          
         DISABLE                    CHECK RE-ENTRANCY COUNT                     
         CW,R9    RUN99                 SHOULD WE RETRY?                        
         BNE      TMGETL0               YES                                     
         LB,R5    R8                    CHECK BYTE 0, R8- WAS                   
         BNEZ     TMGETL5               A FREE ENTRY FOUND?                     
         ENABLE                                                                 
         LI,R15   TYC66             SET R15=NO SPACE TYC                        
         LI,R0    5                 SET R0=RUN CAL ERROR CODE                   
         B        *R8                   5=NO SPACE IN 'FP'                      
*                                                                               
TMGETL5  STH,R1   LMISTAT,R5        STORE LMI STATUS                            
         STD,R10  LMINAME,R5            TASK NAME                               
         LI,R0    0                     JOB ID                                  
         STB,R6   R0                                                            
         STW,R0   LMIJID,R5                                                     
         LD,R0    ZEROS                 ZERO THE REST OF THE LMI                
         STW,R0   LMIPCB,R5             PCB/FWA AND FLAGS                       
         STW,R0   LMIPL,R5              PUBLIBS WORD                            
         STW,R0   LMISDT,R5             SDT HEAD, TASK ID                       
         STB,R0   LMIMAXS,R5            MAX S-ECB COUNT                         
         STB,R0   LMIMAXR,R5            MAX R-ECB COUNT                         
         STW,R0   LMIAET,R5             AET LENGTH AND ADDRESS                  
         STW,R0   LMISECB,R5            S-ECB COUNT AND HEAD                    
         STW,R0   LMIRECB,R5            R-ECB COUNT AND HEAD                    
         STD,R0   LMIRTS,R5             RTS CONTROL DOUBLEWORD                  
*                                                                               
         MTW,1    RUN99             INCREMENT RE-ENTRANCY COUNT                 
*                                                                               
         AI,R8    1                 EXIT TO GOOD EXIT                           
         B        *R8                                                           
         OLAYEND                                                                
        FIN      #MAP                                                           
         END                                                                    
