         SYSTEM   SIG9P                                                         
         SYSTEM   OPTIONS                                                       
         DEF      A:CHECK                                                       
         DEF      DELFPT,CHKBAL,TMSETPSD,TMSETREG                               
         DEF      CHKBALA                                                       
         DEF      FMCHECK,FMCK1,FMCK2,FMCK3,CHECKA                              
         DEF      CHKX8,CHKXR6,CHKX                                             
         DEF      EMSETR3,EMSETR3A                                              
OLAYFLAG EQU      'CHEC'                                                        
         SYSTEM   CPRMON                                                        
CHKXPR8  PULL     R8                EXIT TO R8+1 INCL. INCL PULL                
         AI,R8    1                 EXIT R8+1                                   
CHKX8    B        *R8                                                           
CHKXR6   B        0,R6                                                          
CHKX     B        CALSTDX           STANDARD CAL EXIT R15=TYC                   
         TITLE    '** CHECK **'                                                 
         TITLE    '** CHECK - CHECK CAL1 PROCESSOR AND CHKBAL SUB **'           
*        CHECK    CAL PROCESSOR                                                 
*                                                                               
* ENTRY MAY BE FROM THE CAL1 PROCESSOR, USER (MU=0) OR CAL1 (MU=1)              
*        IN THIS CASE,   R1=FPT CODE                                            
*                        R3=FPT ADDRESS BAL=0                                   
*                        R4=TASK ID                                             
*        EXIT IS TO      CALEXIT (TYC =00-E7) OR CALERR (TYC=F0-FF)             
* BAL ENTRY ALLOWED TO CHKBAL INTERNALLY                                        
*        IN THIS CASE,   R1=FPT CODE (CHECK ,DELFPT OR WAIT CLASS FPT)          
*                        R2=ECB ID                                              
*                        R3=FPT ADDRESS. FPT MUST CONTAIN CODE AND              
*                           P3= 1 IF NO-WAIT, =0 IF WAIT. FPT/DCB ADDR,         
*                           BUSY, ERROR, ABNORMAL EXITS NOT USED                
*     EXITS-+1    ECB IS NOT CHECKABLE (CHK=1,TYPE=00,ETC)                      
*           +2    NORMAL, R15=TYC  (00 BUSY P3=1 ONLY, 01-FF)                   
* ON BAL ENTRIES:                                                               
* REGISTERS USED: R0-R2,R5-R15                                                  
*           SAVED: R3-R4                                                        
* STACK WORDS: 14                                                               
* SUBROUTINES: CHECKING SUBROUTINES                                             
* NOTES: EXITS ENABLED                                                          
*                                                                               
DELFPT   EQU      %                 DELETE FPT ENTRY                            
CHECK    EQU      %                                                             
A:CHECK  EQU      CHECK                                                         
         LW,R15   0,R3              GET EFFECTIVE ADDRESS, FPT                  
         BAL,R0   GETEFADR              OR DCB                                  
         LW,R6    R15                   R6=FPT OR DCB ADDR                      
         LI,R15   0                     R15=TYC=BUSY                            
         DO       #ECB                                                          
         LW,R7    M17                   R6=FPT/DCB ADDRESS                      
         ELSE     #ECB                                                          
         LW,R7    FF01FFFF          IOQECB MASK                                 
         FIN      #ECB                                                          
         LB,R5    STILMID,R4            R5=LMI INDEX                            
*                                                                               
         DISABLE                                                                
*                                                                               
         DO       #ECB                                                          
         LW,R2    LMISECB,R5            R2=ECB ADDRESS                          
CHECK1   CW,R2    M24               SEARCH S-ECB CHAIN                          
         BAZ      CHECKA                END?                                    
         CS,R6    ECBFPT,R2             FPT/DCB ADDR=CHECK VALUE?               
         BE       CHECK2                YES                                     
         LW,R2    ECBSECB,R2            CONTINUE SEARCH,                        
         B        CHECK1                                                        
         ELSE     #ECB                                                          
         STB,R5   R6                PUT IN LMID                                 
         LB,R2    IOQ4              GET NO. OF IOQS                             
CHECK1   CS,R6    IOQECB,R2         THIS IT                                     
         BNE      %+3               NO                                          
         LW,R2    IOQECB,R2         GET WITH CUPCODES                           
         B        CHECK2                                                        
         BDR,R2   CHECK1                                                        
         B        CHECKA            NOT FOUND                                   
         FIN      #ECB                                                          
*                                                                               
*   BAL ENTRIES TO CHECK                                                        
CHKBALA  RES      0                 R3= FPT (WAITANY, TEST)                     
         OR,R3    XBALABIT          SET ALTERNATE BAL BIT                       
         B        %+2                                                           
CHKBAL   RES      0                 R3= FPT (WAITALL)                           
         OR,R3    XBALBIT           SET BAL BIT IN FPT POINTER                  
         PUSH     R8                SAVE EXIT                                   
         LI,R15   0                               SET TYC=0                     
         DO       #ECB                                                          
         DISABLE                                                                
*                                                                               
CHECK2   LW,R6    ECBCTL,R2         TEST VALIDITY OF CHECK                      
         AND,R6   XECBTYPE              IF ECB TYPE=0, CHECK IS                 
         BEZ      CHECK5                     PREMATURE AND NOT                  
*                                            ALLOWED                            
         LW,R0    ECBFPT,R2             IF CHK OR DP=1, CHECK IS                
         CW,R0    XECBCKDP              SIMULTANEOUS OR ON A DELETE-ON-         
         BANZ     CHECK5                POST ECB, NOT ALLOWED.                  
         OR,R0    XECBCHK           SET CHK                                     
         STW,R0   ECBFPT,R2                                                     
*                                                                               
         ENABLE                                                                 
*                                                                               
         LB,R6    EMCHKX,R6         ENTRY TO CHECKING SUBROUTINE                
         LW,R0    EMCHKB,R6             R1=CHECK/DELFPT FPT CODE                
         BAL,R8   *R0     *REG          R2=ECB ID                               
*                         MUST BE    *  R3=CHECK/DELFPT FPT ADDRESS             
*                         SAVED!     *  R4=TASK ID                              
*                                       R5=LM ID                                
*                                       R7=ECB TYPE                             
*                                       R8=LINK                                 
*                                       R15=00                                  
         ELSE     #ECB                                                          
CHECK2   BAL,R8   FMCHECK                                                       
         FIN      #ECB                                                          
         B        CHECK6             +1 EXIT BUSY                               
         BIFBALS  CHKXPR8           BRANCH IF BAL ENTRY                         
         B        CHKX                  IF BAL-TYPE ENTRY, RETURN               
*                                       TO THE CALLER, ELSE GO                  
*                                       TEST TYC, CALERR,CALEXIT                
*                                                                               
         DO       #ECB                                                          
CHECK5   RES      0                 PREMATURE OR DUPLICATE CHECK                
         BIFBALS  CHECK10           B IF HERE VIA ANY BAL                       
         ENABLE                         IF BAL,EXIT DISABLED.                   
         LI,R15   FPTBUSY               EXIT BUSY IF POSSIBLE                   
         BAL,R5   GETFPTN                                                       
         B        CHECK7                NO BUSY                                 
         FIN      #ECB                                                          
*                                       R15= BUSY ADDRESS                       
CHECK6   RES      0                 TAKE BUSY EXIT                              
         BIFBALS  CHECK8            B IF HERE VIA ANY BAL                       
         LW,R9    R15                                                           
         LI,R15   0                                                             
         BAL,R6   TMSETPSD                                                      
         B        CHKX                  NOW DO CALEXIT/CALERR                   
*                                                                               
         DO       #ECB                                                          
CHECK7   LI,R15   TYCTRAP           CALLER ASKED FOR SIMULTANEOUS OR            
         B        CHKX              EXIT TO CALERR                              
         FIN      #ECB                                                          
*                                       EXIT, TRAP HIM.(CAL1 ENTRY)             
*                                                                               
*   EXITS FROM CHECK WHERE ENTRY WAS BY BAL,R8                                  
*                                                                               
CHECK8   LI,R15   0                 BUSY                                        
         DO       #ECB                                                          
         LW,R1    XECBCHK           RESET CHECK BIT IN ECB                      
         LI,R0    0                                                             
         STS,R0   ECBFPT,R2                                                     
         FIN      #ECB                                                          
         B        CHKXPR8           EXIT COMPLETED OR BUSY                      
*                                                                               
         DO       #ECB                                                          
CHECK10  PULL     R8                INVALID CHECK EXIT = +1                     
         B        CHKX8                                                         
CHECKCR  CRASH    'ECB TYPE ERROR, CHECK'                                       
         FIN      #ECB                                                          
*                                   SECOND CHECK LOGIC                          
*                                                                               
*        R1       FPT CODE                                                      
*        R3       FPT ADDRESS (CHECK OR DELFTP)                                 
*        R6       ORIGINAL FPT ADDRESS                                          
*                                                                               
CHECKA   LW,R0    1,R3              SECOND CHECK-IF P1O=0, TYPE I I/O           
         CW,R0    FPTP10                ONLY,                                   
         BANZ     CHECKB                                                        
         BAL,R8   FM2CKDCB                                                      
         B        CHKX              EXIT                                        
*                                                                               
CHECKB   LW,R2    R3                TYPE II I/O OR NON-I/O SERVICE CAL,         
         LW,R3    R6                R3= ORIGINAL FPT ADDRESS                    
         BAL,R8   EM2CKFPT              R1= CHECK/DELFPT CODE                   
         B        CHKX              EXIT - R15 MUST=TYC                         
         PAGE                                                                   
*                                                                               
*        ECB CHECKING SUBROUTINE INDEX TABLE      ONE ENTRY/ECB TYPE            
*                                                                               
         DO       #ECB                                                          
         BOUND    4                                                             
EMCHKX   DATA,1   0           +ECB TYPE   0   ILLEGAL                           
         DATA,1   1           YIELDS      1   I/O                               
         DATA,1   2           INDEX INTO  2   SIGNAL                            
         DATA,1   2           EMCHKB      3   STIMER-USE SIGNAL CHECK           
         DATA,1   4                       4   POLL                              
         DATA,1   2                       5   INIT-USE SIGNAL CHECK             
         DATA,1   6                       6   ENQ                               
         DATA,1   3                       7   MEM REQUEST                       
         DATA,1   5                       8   STDLB                             
*                                                                               
*        ECB CHECKING SUBROUTINE BRANCH TABLE     ONE ENTRY/INDEX               
*                                                                               
EMCHKB      BAL,R0 CHECKCR              0    ERROR                              
         BAL,R0   FMCHECK               1    1-IO                               
         BAL,R0   SIGCHK                2    2,3,5-SIGNAL,STIMER,INIT           
         DO       #ROLL                                                         
         BAL,R0   MMCHECK               3    7-MEM REQUEST                      
         ELSE                                                                   
         BAL,R0   CHECKCR                                                       
         FIN      #ROLL                                                         
         BAL,R0   POLLCHK               4    4-POLL                             
         BAL,R0   STLBCHK               5    8-STDLB                            
         BAL,R0   ENQCHK                6    6-ENQ                              
         FIN      #ECB                                                          
*                                                                               
         TITLE    '** CHECK - TM SUB TO ALTER REG/PSD IN RTS **'                
******************                                                              
*    TMSETREG    *       SUBROUTINES TO ALTER LAST CAL1 RTS R8,R10 AND          
*    TMSETPSD    *            PSD                                               
******************                                                              
*                                                                               
* ENTRY: R9       ERROR CODE                                                    
*        R6       DCB/FPT ADDRESS FOR R10 IN RTS                                
*        BAL,R8   TMSETREG                                                      
* EXIT   +1       R7=RTS R0 LOC                                                 
* ENTRY  R3       FPT ADDRESS                                                   
*        R9       ADDRESS TO STORE IN PSD (=0 IF NONE PROVIDED)                 
*        BAL,R6   TMSETPSD                                                      
* EXIT   +1       R15 ALTERED IF TASK ABORT                                     
*                 R7=RTS R0 LOCATION                                            
* REGISTERS USED: TMSETREG: R6,R7,R8    TMSETPSD: R0,R6,R7,R8,R9,R15 ER         
*           SAVED           R1-R5,R9-R15          R1-R5,R10-R14, R15 OK         
* SUBROUTINES:              NONE                  TMVADR                        
* STACK WORDS               0                     0                             
*                                                                               
*        SUBROUTINE TO CHANGE R8 AND R10 IN RTS                                 
*                                   BAL,R8   TMSETREG                           
*                                   R9=ERROR CODE                               
TMSETREG LB,R7    TCBPOINT          R6= DCB/FPT ADDRESS                         
         LD,R7    STIRTSB,R7            R7=TOP OF RTS AFTER CALENTRY            
         STB,R9   R6                          FPT/DCB ADDRESS IN R10            
         STW,R6   -CAL1PUSH+10,R7       R8 = CAL +1  (FROM ENTRY PSD)           
         LW,R6    -CAL1PUSH+16,R7      (IN RTS)                                 
         AND,R6   M17                                                           
         AI,R6    1                                                             
         STW,R6   -CAL1PUSH+8,R7                                                
         B        CHKX8             EXIT                                        
*                                                                               
*        SUBROUTINE TO CHANGE PSD IN RTS                                        
*                                   BAL,R6   TMSETPSD                           
*                                   R9=ADDRESS TO STORE IN PSD                  
TMSETPSD AND,R9   M17               R3=FPT ADDRESS                              
         BEZ      TMSETP1           R7=RTS REG 0 ADDRESS                        
         BAL,R8   TMVADR            CHECK THE VALIDITY OF THE ADDRESS           
         B        TMSETP2               NOT VALID-LEVEL=ABORT                   
TMSETP0  LB,R7    TCBPOINT          SET R7 TO TOP OF STACK                      
         AW,R7    R7                                                            
         LW,R7    STIRTSB,R7                                                    
         AI,R7    -CAL1PUSH                                                     
         LW,R0    16,R7             ADDRESS OK- CHANGE THE PSD                  
         AND,R0   YFFFE                 ISOLATE NON IA BYTES                    
         AW,R0    R9                    COMBINE                                 
         AI,R0    -1                    DECREMENT IA BY 1 (CALEXIT INCR         
         STW,R0   16,R7                 STORE BACK INTO PSD                     
         B        CHKXR6            EXIT                                        
TMSETP1  LW,R0    1,R3              NO ERROR ADDRESS, IS F7 ON?                 
         CI,R0    1                                                             
         BANZ     CHKXR6                YES-LEAVE PSD UNALTERED                 
TMSETP2  CI,R15   TYCTRAP               NO-RAISE LEVEL TO TRAP                  
         BG       CHKXR6                                                        
         LI,R15   TYCTRAP                                                       
         B        CHKXR6                                                        
         PAGE                                                                   
******************                                                              
*    EM2CKFPT    *       SUBROUTINE TO HANDLE A SECOND CHECK ON A               
******************            STANDARD FPT                                      
*                                                                               
* ENTRY  FROM CHECK      R2=CHECK FPT   R6=ORIG FPT CODE                        
*                        R3=ORIG FPT    R8=LINK                                 
*                        R4=TASK ID     R15=00                                  
* EXIT:  +1       ERROR/NORMAL R15=TYC                                          
*                                                                               
* REGISTERS USED: R0,R5,R8,R14,R15                                              
*           SAVED: R1-R4,R6-R7,R9-R13                                           
* STACK WORDS: 1                                                                
* SUBROUTINES: GETFPTN,TMSETERR                                                 
*                                                                               
EM2CKFPT LW,R0    0,R3              WAS THE ORIGINAL FPT EXTENDED?              
         CW,R0    XFPTP0                                                        
         BANZ     EM2CKF1               YES                                     
         LB,R0    R0                    IS IT STANDARD?                         
         AND,R0   X7F                                                           
         CI,R0    X'40'                                                         
         BGE      *R8                   YES, GIVE NULL EXIT                     
EM2CKF1  LI,R15   FPTTYC            FETCH TYC                                   
         BAL,R5   GETFPTN                                                       
         B        *R8                   NONE                                    
         LW,R3    R2                RESTORE TO THE CHECK FPT                    
*                                       FOR ERROR EXITS                         
         LB,R15   R15               RIGHT JUSTIFY                               
         PUSH     R8                                                            
         BAL,R8   TMSETERR                                                      
         PULL     R8                                                            
         B        *R8                                                           
         TITLE    '** CHECK - FMCHECK - I/O CHECK ROUTINE **'                   
***************                                                                 
*   FMCHECK   *                                                                 
***************                                                                 
*                                                                               
*                                                                               
*                                                                               
*   ROUTINE PROCESSES ALL I/O CHECK CALLS                                       
*   ENTRY IS FROM GENERAL CHECK ROUTINE                                         
*   ROUTINE IS ALSO ENTERED AT FMCK1,FMCK2, AND FMCK3                           
*                                                                               
*    ENTER VIA  BAL,R8  FMCHECK                                                 
*                                                                               
*    AT ENTRY:    R1     FPT CODE                                               
*                 R2     ECB I.D.                                               
*                 R3     FPT ADDRESS (CHECK OR DELFPT)                          
*                 R4     STI INDEX                                              
*                 R8     LINK                                                   
*                                                                               
*    EXIT:        +1     IF I/O NOT DONE AND BUSY ADDR PROVIDED(R15)            
*                 +2     IF I/O DONE ; R15 CONTAINS COMPLETION STATUS           
*                                                                               
*    REGISTERS PRESERVED:      R2,R3,R4,R8                                      
*                                                                               
*                                                                               
*                                                                               
*                                                                               
*                                                                               
FMCHECK  RES      0                                                             
         LW,R0    STITCB,R4                                                     
         CW,R0    XSTIT             IS TASK BEING TERMINATED                    
         BANZ     FMCK2             B IF YES                                    
         LW,R7    R2                SAVE ECB I.D. IN R7                         
         DO       #ECB                                                          
         LW,R0    1,R2              FPT/DCB ADDRESS                             
         PUSH     R4                SAVE R4                                     
         BAL,R4   GETWD             GET ADDR. IN STACK IF FPT/DCB               
         PULL     R4                  IS IN REGISTERS                           
         LW,R2    R0                TRU FPT/DCB ADDR. TO R2                     
         LW,R0    CUPWORD,R7        CLEANUP WORD FROM ECB                       
         LB,R0    R0                CLEANUP CODE                                
         CI,R0    2                 TEST CUPCODE                                
         BE       FMCHECKD          B IF CHECKING A DCB                         
         PUSH     2,R3              SAVE R3,R4                                  
         LW,R3    R2                I/O FPT ADDRESS TO R3                       
         LI,R15   KA                                                            
         BAL,R5   GETFPTN           GET STATUS ADDRESS FROM FPT                 
         B        CHKERROR          ERROR, NOT PRESENT                          
         LW,R15   M17                                                           
         STS,R14  CUPWORD,R7        STORE STATUS ADDR. IN ECB                   
         BAL,R4   GETDCBAD          TRUE DCB ADDR TO R2                         
         PULL     2,R3                                                          
         B        FMCK1                                                         
*                                                                               
FMCHECKD RES      0                 CHECKING A DCB                              
         LW,R14   R2                DCB ADDRESS TO R14                          
         LW,R15   M17               MASK                                        
         STS,R14  CUPWORD,R7        STORE RESOLVED DCB ADDRESS IN ECB           
         ELSE     #ECB                                                          
         LW,R0    R2                R0= LMID,CUPCODE,FPT/DCB ADDR.              
         SLS,R0   -20                                                           
         AND,R0   M3                R0= CLEANUP CODE                            
         CI,R0    2                 ARE WE CHECKING A DCB                       
         BE       FMCHECKD          YES, BRANCH                                 
         BG       FMCK2             B IF NOT CHECKING DCB OR FPT                
*   HERE WE ARE CHECKING AN FPT                                                 
         PUSH     4,R1              SAVE R1-R4                                  
         LW,R3    R2                                                            
         AND,R3   M17               R3= FPT ADDRESS                             
         BAL,R4   GETDCBAD          GET DCB ADDR IN R2                          
         LW,R6    R2                R6= DCB ADDRESS                             
         PULL     4,R1                                                          
         LW,R2    R6                R2= DCB ADDRESS                             
         B        FMCK1                                                         
*   HERE WE ARE CHECKING A DCB                                                  
FMCHECKD RES      0                                                             
         AND,R2   M17               R2= DCB ADDRESS                             
         FIN      #ECB                                                          
*                                                                               
*    AT FMCK1 REGISTERS CONTAIN THE FOLLOWING:                                  
*    R2  DCB ADDRESS                                                            
*    R3  CHECK FPT ADDRESS (ADDRESS OF I/O FPT IF NOT CHECKING)                 
*    R4  TASK ID (STI INDEX)                                                    
*    R7  ECB I.D.                                                               
*    R8  LINK                                                                   
*                                                                               
FMCK1    PUSH     R8                SAVE  LINK                                  
         BAL,R5   CALLSD            SERVICE DEVICE                              
         PULL     R8                                                            
         LW,R1    R2                DCB ADDR. TO R1                             
         LW,R2    R7                ECB I.D. TO R2                              
*                                                                               
*     AT FMCK2 REGISTERS CONTAIN THE FOLLOWING:                                 
*     R1   DCB ADDRESS                                                          
*     R2   ECB I.D.                                                             
*     R3   CHECK FPT ADDRESS IF CHECKING, I/O FPT ADDRESS,OR                    
*          ZERO IF NO FPT                                                       
*     R4   TASK ID (STI INDEX)                                                  
*                                                                               
FMCK2    PUSH     R8                SAVE R8                                     
         BAL,R8   EMWAIT            WAIT FOR I/O COMPLETION                     
         B        FMCKBSY           GO TO BUSY ADDRESS                          
         PULL     R8                I/O DONE, R15= TYC                          
         DO       #ECB                                                          
         CI,R15   K100              HAS ECB BEEN DELETED                        
         BE       FMCHECKH          YES, BRANCH                                 
         FIN      #ECB                                                          
*                                                                               
*   AT FMCK3 REGISTERS CONTAIN THE FOLLOWING:                                   
*   R1   DCB ADDRESS                                                            
*   R2   ECB I.D.                                                               
*   R3   CHECK FPT ADDRESS OR I/O FPT ADDRESS OR ZERO IF NO FPT                 
*   R4 TASK ID (STI INDEX)                                                      
*   R15  TYC                                                                    
*                                                                               
FMCK3    RES      0                                                             
         LW,R0    STITCB,R4                                                     
         CW,R0    XSTIT             IS TASK BEING TERMINATED                    
         DO       #ECB                                                          
         BAZ      FMCHECKG          NO, BRANCH                                  
         PUSH     8,R1              YES                                         
         B        FMCHECKF                                                      
FMCHECKG RES      0                                                             
         DO       #MTAPE                                                        
         CI,R15   6                 IS TYC = EOF CODE                           
         BNE      FMCHECKA          NO, BRANCH                                  
         CI,R3    0                 IS R3 AN FPT ADDRESS                        
         BE       FMCHECKA          NO, BRANCH                                  
         LB,R6    *R3                                                           
         AND,R6   M7                R6= FPT CODE                                
         CI,R6    K1C               IS IT A PFIL CALL                           
         BNE      FMCHECKA          NO, BRANCH                                  
         LW,R5    Y01               YES, SET TYC=1,ARS=0                        
         STW,R5   ECBCOMPL,R2       STORE IN ECB                                
         LI,R5    FMCHECKE          SIMULATE BAL,R5 REQCOM                      
         PUSH     9,R13             SAVE R13-R15,R0-R5                          
         LI,R12   1                 FORCE NORMAL COMPLETION                     
         LW,R13   ECBCOMPL,R2       ARS TO R13                                  
         B        FMCHECKB                                                      
         FIN                                                                    
FMCHECKA RES      0                                                             
         LI,R5    FMCHECKE          SIMULATE BAL,R5 REQCOM                      
         PUSH     9,R13                                                         
         LW,R13   ECBCOMPL,R2       ARS TO R13                                  
         LB,R12   R13               GET TYC                                     
FMCHECKB LW,R10   CUPWORD,R2        GET CLEANUP WORD FROM ECB                   
         B        RC28              POST USER DCB/FPT                           
FMCHECKE PUSH     8,R1              SAVE R1-R8                                  
*                                   MOVE USER DATA RECORD IF                    
*                                    SIDE BUFFERING WAS USED                    
         LW,R7    0,R2              GET DATA AREA ADDRESS FROM ECB              
         BEZ      FMCHECKC          BRANCH IF NOT PRESENT                       
         LW,R6    1,R7              WORD 1 IN DATA AREA                         
         LB,R0    R6                IOD PARAMETER TO R0                         
         CI,R0    IOD2                                                          
         BNE      FMCHECKC          NO SIDE BUFFER TO MOVE                      
         LW,R4    2,R7              WORD 2 IN DATA AREA                         
         LW,R14   ECBCOMPL,R2       GET ARS FROM ECB                            
         AND,R14  M17                                                           
         BAL,R9   MOVEBYTS          MOVE RECORD TO USER BUFFER                  
FMCHECKC RES      0                                                             
         LW,R15   ECBCOMPL,R2       COMPL STATUS TO R15                         
         LB,R15   R15               TYC                                         
         LW,R0    CUPWORD,R2        CLEANUP WORD FROM ECB                       
         LB,R0    R0                CLEANUP CODE TO R0                          
         CI,R0    2                 DONT CALL TMSETERR                          
         BG       FMCHECKF           IF CUPCODE IS 3 OR 4                       
         XW,R1    R2                R1=ECB I.D, R2= DCB ADDR                    
         BAL,R8   TMSETERR                                                      
         XW,R1    R2                R1=DCB ADDR, R2= ECB I.D.                   
FMCHECKF RES      0                                                             
         BAL,R8   FMRELRAD          UNLOCK I/O BUFFER                           
         LI,R8    0                                                             
         STW,R8   ECBRECB,R2        ZERO R-TASK DATA                            
         BAL,R8   EMDELECB          DELETE USER ECB                             
         B        IOCRASH           SYSTEM ERROR                                
         ENABLE                                                                 
         PULL     8,R1                                                          
         ELSE     #ECB                                                          
         BANZ     FMCHECKH          YES, EXIT                                   
*   WHEN #ECB=0, TYC MUST BE OBTAINED FROM THE STATUS COMPLETION                
*   WORD.                                                                       
         LI,R15   1                 PRE-SET TYC TO NORMAL                       
         CI,R2    X'40000'          TEST STATUS ADDRESS BIT                     
         BAZ      FMCHECKA          B IF ADDRESS IS DCB OR FPT                  
         LB,R15   *R2               R2 IS STATUS ADDR, GET TYC                  
         B        FMCHECKC          BRANCH                                      
FMCHECKA RES      0                                                             
         LW,R0    R2                R0= ECB ID WORD                             
         SLS,R0   -20                                                           
         AND,R0   M3                R0= CLEANUP CODE                            
         CI,R0    2                 TEST CUPCODE                                
         BE       FMCHECKB          B IF DCB CONTAINS TYC                       
         BG       FMCHECKH          B IF TYC NOT AVAILABLE                      
         LW,R6    R3                SAVE R3                                     
         LW,R3    R2                                                            
         AND,R3   M17               R3= ORIGINAL REQUEST FPT ADDRESS            
         BEZ      FMCHECKH          B IF NOT FPT ADDRESS                        
         LI,R15   10                                                            
         BAL,R5   GETFPTN           GET STATUS ADDRESS IN R14                   
         B        CHKERROR          ERROR                                       
         LW,R3    R6                R3= CHECK FPT ADDRESS                       
         LB,R15   *R14              R15= TYC                                    
         B        FMCHECKC                                                      
FMCHECKB RES      0                                                             
         LI,R6    9                 BYTE OFFSET FOR TYC IN DCB                  
         LB,R15   *R2,R6            R15= TYC                                    
         SLS,R15  -1                POSITIONS                                   
FMCHECKC RES      0                                                             
         DO       #MTAPE                                                        
         CI,R15   6                 IS TYC= EOF                                 
         BNE      FMCHECKE          NO, BRANCH                                  
         CW,R2    Y0008             YES, IS THIS A PFIL                         
         BAZ      FMCHECKE          NO, LEAVE TYC=6                             
         LI,R15   1                 YES, SUBSTITUTE NORMAL TYC                  
FMCHECKE RES      0                                                             
         FIN      #MTAPE                                                        
         CI,R3    0                 IS R3 AN FPT ADDRESS                        
         BE       FMCHECKH          NO, EXIT                                    
         LW,R0    R2                                                            
         SLS,R0   -20                                                           
         AND,R0   M3                R0= CLEANUP CODE                            
         CI,R0    2                                                             
         BG       FMCHECKH          B IF NOT DCB,FPT I/O                        
         PUSH     R8                                                            
         XW,R1    R2                R1= ECBID,R2= DCB ADDR                      
         BAL,R8   TMSETERR          CHANGE PSD,R8,R10 IF APPLICABLE             
         XW,R1    R2                SWITCH AGAIN                                
         PULL     R8                                                            
         FIN      #ECB                                                          
FMCHECKH RES      0                                                             
         AI,R8    1                                                             
         B        CHKX8             NORMAL RETURN (+2)                          
*                                                                               
FMCKBSY  RES      0                 I/O BUSY, BUSY ADDR PROVIDED                
         PULL     R8                RESTORE REGISTER                            
         B        CHKX8             TAKE BUSY EXIT  (+1)                        
*                                                                               
CHKERROR PULL     2,R3                                                          
         LI,R15   TYCABORT          SET TYC FOR ABORT                           
         AI,R8    1                                                             
         B        CHKX8             RETURN +2                                   
         PAGE                                                                   
****************                                                                
*   FM2CKDCB   *                                                                
****************                                                                
*                                                                               
*                                                                               
*   ROUTINE PROCESSES CHECK CALLS WHEN A SERVICE HAS ALREADY                    
*    BEEN CHECKED AND THE ECB HAS BEEN DELETED.                                 
*                                                                               
*                                                                               
*   AT ENTRY:     R1      CHECK OR DELFPT FPT CODE                              
*                 R3      CHECK OR DELFPT FPT ADDRESS                           
*                 R4      TASK  I.D.                                            
*                 R8      LINK                                                  
*                 R15     ZERO                                                  
*                                                                               
*                                                                               
*                                                                               
*                                                                               
FM2CKDCB RES      0                                                             
         BAL,R4   GETDCBAD          GET TRUE DCB ADDR. IN R2                    
         LW,R15   2,R2              GET WORD WITH TYC FROM DCB                  
         SLS,R15  -17               R15= TYC                                    
         PUSH     R8                TYC NOT NORMAL                              
         BAL,R8   TMSETERR          SET UP R8,R10 ETC.                          
         PULL     R8                                                            
         B        *R8               EXIT BACK TO CHECK CAL PROCESSOR            
         TITLE    '** CHECK - ECB SUBROUTINE TO SET R3 = FPT ADDR **'           
***************                                                                 
*   EMSETR3   *                                                                 
*   EMSETR3A  *                                                                 
***************                                                                 
*                                                                               
*   ROUTINE CONVERTS AN  FPT ADDRESS FROM A REGISTER VALUE TO                   
*   AN ADDRESS IN THE USER'S RTS STACK.                                         
*                                                                               
*   AT ENTRY: R2  ECB ADDRESS                                                   
*             R3  MU AND BAL BITS IN BYTE 0                                     
*        BAL,R8   EMSETR3                                                       
*                                                                               
*   OR                                                                          
*                                                                               
*             R3= FPT ADDRESS (MAY BE REGISTER) TO BE MODIFIED; MU              
*                 AND BAL BITS IN BYTE 0.                                       
*        BAL,R8   EMSETR3A                                                      
*                                                                               
*   AT EXIT   R3= WORKING FPT ADDRESS, MU AND BAL BITS UNALTERED.               
*                                                                               
*   ALWAYS RETURNS +1                                                           
*   REGISTERS USED:  R0,R3,R8                                                   
*   REGISTERS SAVED:   R1,R2,R4-R7,R9-R15                                       
*   STACK WORDS:  NONE                                                          
*   SUBROUTINES USED:  NONE                                                     
*                                                                               
*                                                                               
EMSETR3A RES      0                                                             
         LB,R0    R3                SAVE MU AND BAL BITS                        
         B        EMSETR3B                                                      
EMSETR3  RES      0                                                             
         LB,R0    R3                SAVE MU AND BAL BITS                        
         LW,R3    ECBFPT,R2         GET THE FPT ADDRESS FROM THE ECB            
EMSETR3B AND,R3   M24               R3= FPT ADDRESS                             
         CI,R3    16                TEST FOR REGISTER (0-15)                    
         STB,R0   R3                STORE MU AND BAL BITS IN FPT ADDRESS        
         BGE      CHKX8             EXIT IF NOT A REGISTER                      
         LW,R0    R3                SAVE R3 IN R0                               
         LB,R3    TCBPOINT          GET THE RTS STACK ADDRESS AND               
         SLS,R3   1                   CONVERT THE REGISTER NUMBER TO            
         LW,R3    STIRTSB,R3          THE CORE LOCATION IN THE RTS.             
         AW,R3    R0                                                            
         AI,R3    -CAL1PUSH                                                     
         B        CHKX8             EXIT *R8                                    
         OLAYEND                                                                
         END                                                                    
