         PCC      0                                                             
         SYSTEM   SIG5P                                                         
         SYSTEM   OPTIONS                                                       
         DO       #SYMB                                                         
*   ENTRY POINTS                                                                
         DEF      JOB2                                                          
         DEF      JOBDLTE                                                       
         DEF      JOBDLTEA                                                      
         DEF      SETPRI                                                        
         DEF      JOBMSG                                                        
         DEF      SMDFIS,SMDFOS                                                 
*   EXIT POINTS                                                                 
         DEF      JOBDX                                                         
         DEF      SETPX                                                         
         DEF      JOB2X1,JOB2X2                                                 
         DEF      JOBMSGX                                                       
*                                                                               
OLAYFLAG EQU      'JOB2'                                                        
         SYSTEM   CPRMON                                                        
         PAGE                                                                   
         SPACE    3                                                             
*********************************************************************           
*                                                                               
*                                                                               
JOB2     RES      0                                                             
*                                                                               
*   EXITS                                                                       
*                                                                               
JOB2X1P  RES      0                                                             
         PULL     R5                RESTORE LINK                                
JOB2X1   B        0,R5                                                          
JOB2X2P  RES      0                                                             
         PULL     R5                                                            
JOB2X2   B        1,R5                                                          
         TITLE    '** JOB2 **'                                                  
         TITLE    '** JOB2 - JOBDLTE SUBROUTINE **'                             
*************                                                                   
*  JOBDLTE  *                                                                   
*  JOBDLTEA *                                                                   
*************                                                                   
*                                                                               
*   JOBDLTE ROUTINE DELETES ALL FILES IN THE GIVEN AREA WHICH                   
*   ARE ASSOCIATED WITH THE SPECIFIED JOB#                                      
*                                                                               
*   JOBDLTEA ROUTINE DELETES ALL FILES IN THE GIVEN AREA WHICH                  
*   ARE ASSOCIATED WITH THE SPECIFIED JOB EXCEPT THE CURRENT FILE.              
*                                                                               
*                                                                               
*   ENTRY REGISTERS:                                                            
*                 R6   AREA INDEX                                               
*                 R8   LINK                                                     
*                 R10  BBCW LOC (BLOCKING BUFFER CONTROL WORD LOCATION)         
*                 R12  1ST WORD OF FILE NAME (JOBDLTEA CALL ONLY)               
*                 R13  2ND WORD OF FILE NAME (JOBDLTEA CALL ONLY)               
*                R13  JOB NUMBER IN EBCDIC (BITS 8-31) (JOBDLTE CALL ONLY)      
*                                                                               
*   ROUTINE RETURNS +2 IF NO ERRORS; +1 IF ERRORS (R15= TYC)                    
*                                                                               
JOBDLTEA RES      0                                                             
         LI,R7    0                 FLAG FOR ALTERNATE ENTRY                    
         B        JOBD03                                                        
JOBDLTE  RES      0                                                             
         LW,R12   R13               R12= JOB# TO COMPARE                        
         LW,R13   M24               MASK FOR COMPARE                            
         LI,R7    -1                FLAG FOR DELETE ALL                         
JOBD03   RES      0                                                             
         PUSH     R8                SAVE RETURN LINK                            
         LI,R14   0                 SET TO START IN 1ST DIRE SECTOR             
*                                                                               
*                                                                               
JOBD05   RES      0         READ NEXT DIRECTORY SECTOR                          
         LW,R15   RENT:D            GET REENTRANCE COUNT                        
         PUSH     R15               SAVE REENTRANCE COUNTER                     
         BAL,R8   READDIR           READ DIRE SECTOR R14                        
         B        JOBD40              ERROR: TEST TYPE OF ERROR                 
*                                                                               
         LI,R15   0                 SET NO FILES DELETED IN THIS SECTOR         
         LI,R4    X'1FFFF'          POINT AT START OF DIRE BUFFER               
         AND,R4   *R10                                                          
         LI,R0    X'1FFFF'          GET LENGTH OF INFO IN THE DIRE              
         AND,R0   0,R4              GET ADDRESS OF LAST+1 WORD TO TEST          
         AW,R0    R4                IN THE BUFFER                               
         AI,R4    4                 POINT AT FIRST WORD OF 1ST ENTRY            
*                                                                               
*                                                                               
JOBD10   RES      0         TEST NEXT ENTRY IN THE DIRECTORY                    
         CW,R4    R0                ARE WE AT THE END OF THE INFO THERE ?       
         BGE      JOBD22              YES, TEST IF MORE DIRE SECTORS            
*                                                                               
         LW,R8    DIRENAM1,R4       GET THE FILE'S NAME                         
         LW,R9    DIRENAM2,R4         INTO R8 AND R9                            
         CI,R7    -1                IS THIS A DELETE ALL CALL                   
         BE       JOBD15            YES, BRANCH                                 
         PUSH     15,R0             SAVE R0-R14                                 
         SLD,R8   8                 RIGHT JUSTIFY BOTH JOB'S NUMBERS            
         SLD,R12  8                  IN THE EVEN REGISTER OF THE PAIRS          
         CW,R8    R12               ARE THEY THE SAME JOB ?                     
         BNE      JOBD13            NO, CAN'T DLETE THIS ONE                    
*   COMPARE EXTENSION NUMBERS OF THE TWO FILES. THE FILE WILL                   
*   BE DELETED IF ITS EXTENSION NUMBER IS LESS THAN THAT OF                     
*   THE CALLER'S.                                                               
         SLS,R13  -8                R13= EXTENSION # IN BITS 8-31               
         LI,R4    3                 CONVERT THREE CHARACTERS                    
         BAL,R8   SMBCDHEX          CONVERT TO BINARY                           
         LW,R11   R14               SAVE EXTN NUMBER OF FILE IN DIRE.           
         LW,R13   R9                COPY AND RIGHT JUSTIFY IN R13 THE           
         SLS,R13  -8                EXT # OF FILE TO BE DELETED                 
         LI,R4    3                                                             
         BAL,R8   SMBCDHEX          CONVERT TO BINARY                           
         CW,R14   R11                                                           
         BGE      JOBD13            B IF THIS FILE NOT TO BE DELETED            
         PULL     15,R0             THIS FILE WILL BE DELETED                   
         B        JOBD17                                                        
JOBD13   RES      0                                                             
         PULL     15,R0                                                         
         B        JOBD20            B TO TRY NEXT FILE ENTRY                    
JOBD15   RES      0                                                             
         SCD,R8   8                 RIGHT JUSTIFY JOB NUMBER IN R8              
         CS,R12   R8                DO THE JOB NUMBERS MATCH ?                  
         BNE      JOBD20            NO                                          
JOBD17   RES      0                                                             
         LI,R8    0                 CLEAR THE FILE'S ENTRY                      
         STW,R8   DIRENAM1,R4       ITS NAME,                                   
         STW,R8   DIRENAM2,R4                                                   
         STW,R8   DIREGRSZ,R4       GSIZE & RSIZE, AND                          
         STW,R8   DIREFSIZ,R4       FINALLY FSIZE                               
         AI,R15   1                 INCR FLAG TO WRITE DIRECTORY                
JOBD20   RES      0         STEP TO NEXT ENTRY                                  
         LW,R8    DIRELEN,R4        GET THE ENTRY'S LENGTH                      
         AND,R8   M8                AND STEP POINTER OVER ENTRY                 
         AW,R4    R8                                                            
         B        JOBD10            LOOP TO TEST IF MORE, NEXT ENTRY            
*                                                                               
*                                                                               
*   HERE WE HAVE EXHAUSTED THE CURRENT SECTOR IN                                
*   OUR SEARCH.  IF THE DIRECTORY IS CONTINUED THE NEXT                         
*   SECTOR WILL BE READ INTO CORE.  OTHERWISE WE ARE DONE.                      
*                                                                               
JOBD22   RES      0         END OF CURRENT SECTOR; TEST IF ALTERED              
         CI,R15   0                 WAS THE DIRECTORY UPDATED                   
         BE       JOBD25            NO, DON'T WRITE IT OUT                      
         PULL     R15               GET ACTIVITY COUNT                          
         PUSH     R15               SAVE IT AGAIN                               
         BAL,R8   WRITDIR           WRITE OUT UPDATED DIRECTORY                 
         B        JOBD40            ERROR                                       
*                                                                               
JOBD25   RES      0                                                             
         PULL     R15                                                           
         LI,R4    X'1FFFF'          POINT AT START OF DIRE BUFFER AGAIN         
         AND,R4   *R10                                                          
         LW,R0    0,R4              IS THE DIRE LINKED TO ANOTHER ?             
         BGEZ     JOBD30              NO, PROCESSED LAST SECTOR: EXIT           
*                                                                               
         LW,R14   1,R4              YES, GET LINK TO NEXT DIRE SECTOR           
         B        JOBD05            AND GO PROCESS IT                           
*                                                                               
*                                                                               
JOBD30   RES      0         JOB NO LONGER IN DIRECTORY: EXIT DONE OK            
         PULL     R8                RECOVER LINK                                
         AI,R8    1                 STEP TO EXIT OK                             
         B        JOBDX             AND EXIT THERE                              
*                                                                               
JOBD35   RES      0         RETURN AN ERROR: TYC IN R15                         
         PULL     R8                RECOVER LINK FOR ERROR EXIT                 
JOBDX    B        *R8               RETURN +2 (NORMAL)                          
*                                                                               
JOBD40   RES      0                                                             
         PULL     R15               CLEAR STACK OF RENT:D                       
         LW,R15   R9                COPY ERROR TYC                              
         CI,R15   TYCREENT          WERE WE REENTERED                           
         BNE      JOBD35              NO, EXIT WITH ERROR TYC IN R15            
         B        JOBD05            YES, READ DIRECTORY AGAIN                   
         TITLE    '** JOB2 - SMDFOS SUBROUTINE **'                              
*************                                                                   
*   SMDFOS  *                                                                   
*************                                                                   
*   SMDFIS  *                                                                   
*************                                                                   
*                                                                               
*   SMDFOS SUBROUTINE DELETES A JOB'S FILES IN THE OS AREA.                     
*   SMDFIS SUBROUTINE DELETES A JOB'S FILES IN THE IS AREA.                     
*                                                                               
*   AT ENTRY:     R1   DCT INDEX                                                
*                 R5   LINK                                                     
*                 R13  JOB NUMBER (BITS 8-31)                                   
*                                                                               
*   ROUTINE RETURNS +2 IF NO ERRORS                                             
*                   +1 IF ERROR, R15=ERROR CODE                                 
*                                                                               
SMDFIS   RES      0                 ENTRY TO DELETE IS AREA FILES               
         LI,R8    KIS               GET INDEX FOR IS AREA                       
         B        SMDFOS5                                                       
SMDFOS   RES      0                                                             
         LI,R8    KOS               GET OS AREA INDEX                           
SMDFOS5  RES      0                                                             
         PUSH     R5                SAVE LINK                                   
         PUSH     R1                SAVE DCT INDEX                              
         LI,R1    -1                PSEUDO FPT CODE FOR FINDBB                  
         BAL,R5   FINDBB            GET A BLK BUFFER                            
         B        SMDFOS10          NONE AVAILABLE                              
         BAL,R5   FMMASTX                                                       
         NOP                                                                    
         LW,R10   R15               SET BBCW LOC FOR JOBDELETE                  
         BAL,R8   JOBDLTE           DELETE JOB(S FILES IN OS AREA               
         B        SMDFOS20          ERROR                                       
         LW,R6    R10               SET BBCW LOC SO WE CAN                      
         BAL,R11  RELADBUF          RELEASE THE BLK BUFFER                      
         PULL     R1                RESTORE DCT INDEX                           
         B        JOB2X2P           TAKE NORMAL EXIT                            
*                                                                               
*   ERROR PROCESSSING                                                           
*                                                                               
SMDFOS10 RES      0                                                             
         LI,R15   K55               ERROR FOR NO BLK BUFFER                     
         B        SMDFOS30                                                      
*                                                                               
SMDFOS20 RES      0                                                             
         LW,R6    R10               SET BBCW LOC SO WE CAN                      
         BAL,R11  RELADBUF          RELEASE THE BLK BUF                         
SMDFOS30 RES      0                                                             
         PULL     R1                                                            
         B        JOB2X1P                                                       
         TITLE    '** JOB2 - SETPRI SUBROUTINE **'                              
************                                                                    
*  SETPRI  *                                                                    
************                                                                    
*                                                                               
*   SUBROUTINE STORES THE JOB PRIORITY IN THE APPROPRIATE SYMBIONT              
*   FILE DIRECTORY ENTRY.                                                       
*                                                                               
*   AT ENTRY:                                                                   
*                 R6   AREA INDEX                                               
*                 R8   LINK                                                     
*                 R10  PRIORITY TO ASSOCIATE WITH SPECIFIED JOB                 
*                 R12  FILE NAME WORD 1                                         
*                 R13  FILE NAME WORD 2                                         
*                                                                               
*   ROUTINE RETURNS +2 IF NO ERRORS                                             
*   ROUTINE RETURNS +1 IF ERROR, R15 CONTAINS TYC                               
*                                                                               
SETPRI   RES      0                                                             
         PUSH     12,R3             SAVE R3-R14                                 
         LW,R3    R10               R3= PRIORITY OF JOB                         
         LW,R15   RENT:D            GET REENTRANCE COUNT                        
         LI,R7    0                 SET R7 FOR FINDDIR                          
         LD,R10   SYSACNT           SET ACCOUNT FOR ALL SYMBIONT FILES          
         BAL,R8   FINDDIR           FIND THE FILE'S ENTRY                       
         B        SETPE1            ERROR                                       
*                                                                               
*   RESULTS RETURNED BY FINDDIR:                                                
*        R4       ADDRESS OF FILE'S DIRE ENTRY IN BLOCKING BUFFER               
*        R6       AREA INDEX (UNCHANGED)                                        
*        R10      ADDRESS OF BBCW FOR BLOCKING BUFFER                           
*        R12,R13  FILE NAME (UNCHANGED)                                         
*        R14      SECTOR NUMBER OF THE DIRECTORY SECTOR                         
*        THE OTHER REGISTERS ARE ALSO UNCHANGED                                 
*                                                                               
         LI,R5    DIRPRI                                                        
         LH,R8    *R4,R5            GET HW WITH PRIORITY                        
         LI,R9    X'FF0F'           GET MASK TO                                 
         AND,R8   R9                REMOVE OLD PRIORITY                         
         SLS,R3   4                                                             
         AW,R8    R3                MERGE NEW PRIORITY                          
         STH,R8   *R4,R5            STORE NEW PRIORITY                          
*                                                                               
         BAL,R8   WRITDIR           WRITE THE UPDATED DIRECTORY SECTOR          
         B        SETPE2            ERROR                                       
         LW,R6    R10               SET BBCW ADDRESS SO WE CAN                  
         BAL,R11  RELADBUF          RELEASE THE BLK BUF                         
         PULL     12,R3                                                         
         AI,R8    1                 INCREMENT RETURN ADDRESS                    
SETPX    B        *R8               RETURN                                      
*                                                                               
SETPE1   RES      0                                                             
         LW,R15   R9                R15= TYC                                    
         PULL     12,R3             RESTORE R3-R14                              
         CI,R15   TYCREENT          WERE WE RE-ENTERED                          
         BE       SETPRI            YES, START OVER                             
         B        SETPX             EXIT +1                                     
*                                                                               
SETPE2   RES      0                                                             
         LW,R15   R9                COPY ERROR TYC                              
         LW,R6    R10               SET BBCW LOC AND                            
         BAL,R11  RELADBUF          RELEASE THE BLK BUF                         
         PULL     12,R3                                                         
         CI,R15   TYCREENT          WERE WE RE-ENTERED                          
         BE       SETPRI            YES, START OVER                             
         B        SETPX                                                         
         TITLE    '** JOB2 - JOBMSG SUBROUTINE **'                              
************                                                                    
*  JOBMSG  *                                                                    
************                                                                    
*                                                                               
*   ROUTINE QUEUES JOB MESSAGES FOR OUTPUT TO THE OC DEVICE.                    
*   NUMBER OF BYTES TO OUTPUT IS IN BYTE 0 OF THE MESSAGE                       
*   ROUTINE ALWAYS RETURNS +1.                                                  
*                                                                               
*   R2   WORD ADDRESS OF BUFFER                                                 
*   R5   LINK                                                                   
*                                                                               
JOBMSG   RES      0                                                             
         PUSH     R5                SAVE LINK                                   
*   GET TSPACE FOR BUFFER AND MOVE MESSAGE                                      
         LB,R7    *R2               R7= # OF BYTES IN MESSAGE                   
         CI,R7    3                                                             
         BAZ      %+2                                                           
         AI,R7    4                                                             
         SLS,R7   -2                R7= # OF TSPACE WORDS TO GET                
         BAL,R8   GETTEMP           GET IT                                      
         B        JOBMSG5           NONE, EXIT                                  
         ENABLE                                                                 
         PUSH     R7                SAVE POINTER TO TSPACE                      
         LB,R14   *R2               R14= BYTE COUNT                             
         LW,R6    R2                                                            
         SLS,R6   2                 R6 = BYTE ADDRESS OF BUFFER                 
         LW,R4    R7                                                            
         SLS,R4   2                 R4= TO ADDR                                 
         BAL,R9   MOVEBYTS          MOVE THE MESSAGE TO TSPACE                  
         LI,R8    K3                FAKE DCB WORD 0                             
         LI,R7    OC                                                            
         BAL,R4   GETDCTX           GET DCT INDEX FOR OC IN R7                  
         NOP                                                                    
         PULL     R9                R9= TSPACE ADDRESS                          
         LI,R2    0                                                             
         LI,R4    FCWKPWNL          FUNCION CODE                                
         LI,R6    0                 NUMBER OF RETRIES                           
         LW,R8    SMCUP3            BRANCH-TYPE CLEANUP                         
         LW,R10   R9                R10= WORD ADDRESS OF BUFFER                 
         AND,R10  M17               MASK                                        
         SLS,R10  2                 R10= BYTE ADDR OF BUFFER                    
         LB,R11   *R9               GET SAVED BYTE COUNT                        
         LI,R5    '!'                                                           
         STB,R5   *R9               REPLACE BYTE 0 WITH ANOTHER BANG            
         LB,R5    TCBPOINT          TASK ID                                     
         LW,R13   STIPRIO,R5                                                    
         LB,R13   R13               R13= PRIORITY                               
         BAL,R5   QUEUE             QUEUE THE REQUEST                           
         NOP                                                                    
JOBMSG5  RES      0                                                             
         PULL     R5                                                            
JOBMSGX  B        0,R5                                                          
         OLAYEND                                                                
         FIN      #SYMB                                                         
         END                                                                    
