*M*      UCAL     TO PROCESS A SUB-SET OF USER CALS.
*P*
*P*      NAME:    UCAL
*P*
*P*      PURPOSE: TO PROCESS THE FOLLOWING CALS:
*P*                   M:GDDL        GET DYNAMIC DATA LIMITS
*P*                   M:WAIT        SUSPEND PROGRAM
*P*                   M:CT          CHANGE TERMINAL TYPE
*P*                   M:TS          OBTAIN TERMINAL STATUS
*P*               M:TS2             OBTAIN TERMINAL STATUS (EXTENDED)
*P*               M:TS3             OBTAIN TERMINAL STATUS (2ND EXTENSION)
*P*               M:STA             SET TERMINAL ATTRIBUTES
*P*                   M:CAC         CHANGE ACTIVATION CHARACTER
*P*                                 ASSOCIATE SHARED PROCESSOR
*P*                                 DISASSOCIATE SHARED PROCESSOR
*P*                                 SAVE CAL
*P*                                 GET CAL
*P*                   M:KEYIN       REQUEST AN OPERATOR KEYIN
*P*
         PAGE
2741CODE SET      1                 SET FOR 2741 CAPABILITY
UFLAGS   SET      1
         SYSTEM   UTS
         PCC      0
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
SR1      EQU      8
R8       EQU      8
SR2      EQU      9
R9       EQU      9
SR3      EQU      10
R10      EQU      10
SR4      EQU      11
R11      EQU      11
D1       EQU      12
R12      EQU      12
D2       EQU      13
R13      EQU      13
D3       EQU      14
R14      EQU      14
D4       EQU      15
R15      EQU      15
         PAGE
*
*        MODULE DEFS
*
UCAL:    RES
         DEF      UCAL:             PATCHING DEF
*
*        JIT REFS
*
         REF      J:JIT             WORD ADDR OF THE JIT
         REF      J:ACCN            2 WORDS FOR USER'S ACCOUNT
         REF      J:UNAME           3 WORDS FOR USER'S NAME
         REF      J:BASE            SPILL BUFFER FOR INDEX BUFFERS
         REF      J:CFLGS           USER FLAGS FOR TEL SAVE/GET CAL
         REF      J:CPROCS          PROCESSORS ASSOCIATED AT TIME OF SAVE CAL
         REF      J:CCBUF           CONTROL COMMAND BUFFER
*,*                                  USED TO OUTPUT GJOB ERR MESSAGE
         REF      J:INTENT          BREAK CONTROL ROUTINE ADDR
         REF      J:DCBLINK         ADDR OF THE DCB TABLE
         REF      J:RNST            RUN STATUS
         REF      J:TELFLGS         FLAGS USED BY TEL AND CCI
         REF      J:EUP             VP# OF ENDING USER'S PAGE
         REF      J:DLL             VP# OF FIRST DATA PAGE
         REF      J:DUL             VP# OF LAST DATA PAGE
         REF      J:DCBLL           VP# OF FIRST DCB PAGE
         REF      J:PLL             VP# OF FIRST PROCEDURE PAGE
         REF      J:PUL             VP# OF LAST PROCEDURE PAGE
         REF      J:DDLL            VP# OF FIRST DYNAMIC DATA PAGE
         REF      J:DDUL            VP# OF LAST DYNAMIC DATA PAGE
         REF      JB:COCOPT2        COC OPTIONS
         REF      JB:PCP            # OF PGS OF PROC/DATA/DYN. DATA/CONTEXT
         REF      JB:PCC            # OF PAGES OF CONTEXT
         REF      JB:PCDCB          # OF PGS OF DCBS (BYTE 0)
         REF      JB:PCDD           # OF PAGES OF DYNAMIC DATA
         REF      JEUPVP            DEFAULT END USER PAGE (X'DF')
         REF      SBUF2VPA          WORD ADDR OF SPECIAL BUFFER 2
         REF      JXBUFVP           VP# OF FIRST SPARE BUFFER
         REF      JOVVPA            WORD ADDR OF OVERLAY AREA
         REF      JSPVP             VP ADDR OF SPEC. PROC. AREA
         REF      JB:FBUL           VP# OF HIGHEST FILE MNG SPARE BUFFER
         REF      JX:CMAP           USER'S PHYSICAL PAGE MEMORY MAP
         REF      JBCBUC            COOP SPARE BUFFER USE COUNT
         REF      JBFBUC            FILE MGMT SPARE BUFFER USE COUNT
         REF      JB:MNPA           USER'S MAX CORE PAGES
         REF      JBNRG             # OF REMAINING GRANULES
         REF      J:CLE             # OF WORDS IN SWAPPER COMMAND LIST
         REF      JCCL              MAX # OF WORDS IN JIT FOR SWAPPER
*,*                                   COMMAND LIST
         REF,1    JB:PCW            PLATEN WIDTH (# OF CHAR. PER LINE)
         REF,1    JB:LPP            # OF LINES PER TERMINAL PAGE
         REF,1    JB:PNR            PARTION # UNDER WHICH JOB IS RUNNING
         REF      JH:LDCF           PERIPHERAL AUTHORIZATION FLAGS
         REF      M:UC              M:UC DCB FOR ON-LINE USER
         REF      COCLN             DISPLACEMENT INTO M:UC TO LINE #
         REF      J:AJ              PP# OF AJIT PAGE
         REF      JB:PROMPT         PROMPT CHARACTER
*
*        USER TABLE REFS
*
         REF      UH:FLG            USER FLAGS
         REF      U:MISC            FOR WAIT EVENT
         REF      UB:ACP            USER'S COMMAND PROCESSOR #
         REF      UB:APR            ASSOCIATED STANDARD SHARED PROCESSSOR #
         REF      UB:APO            OVERLAY # OF ASSOCIATED SHARED PROCESSOR
         REF      UB:ASP            ASSOCIATED SPECIAL SHARED PROCESSOR #
         REF      UB:DB             ASSOCIATED DEBUGGER #
         REF      UB:PCT            USER'S PAGE COUNT
         REF      UH:DL             FOR BREAK ON T:ASSOC. DELTA
*
*        SHARED PROCESSOR TABLE REFS
*
         REF      P:NAME            ROOT OR OVERLAY NAME IN TEXTC FORMAT
         REF      PNAMEND           INDEX# + 1 OF LAST ROOT ENTRY
         REF      PPROCS            INDEX# + 1 OF LAST OVERLAY ENTRY
         REF      P:SA              FLAGS AND START ADDRESS
         REF      PB:PSZ            # OF PAGES OF PURE PROCEDURE
         REF      PB:PVA            VP# OF FIRST PROCEDURE PAGE
         REF      PB:HVA            VP# OF LAST PROCEDURE PAGE +1
         REF      PB:LNK            PROCESSOR TABLE INDEX OF NEXT OVERLAAY
         REF      PB:UC             # OF IN-CORE USERS ASSOCIATED
         REF      PB:REP            TOTAL # OF USERS ASSOCIATED
*
*        GHOST JOB TABLE REFS
*
         REF      S:GJOBTBL         TEXTC NAME OF GHOST JOBS
*
*        MONITOR DATA
*
         REF      S:CUN             CURRENT USER NUMBER
         REF      S:PCORE           USED BY M:GDDL CAL PROCESSING
         REF      SL:CORE           USED BY M:GDDL CAL PROCESSING
         REF      DATE              CURRENT DATE
         REF      TIME              CURRENT TIME
         REF      OCDCT             DCT INDEX OF OC
         REF      SB:RBMX           SYST. LIMIT FOR BATCH CORE (M:GDDL)
         REF      SB:ROMX           SYST. LIMIT FOR ON-LINE CORE (M:GDDL)
*
*        MASKS
*
         REF      MASKS             1->32 BIT MASKS
         REF      BT31TO0           1 BIT MASKS
         REF      NB31TO0           31 BIT MASKS
         REF      XFC
         REF      Y002
         REF      Y003E
         REF      Y008
         REF      Y2
         REF      Y4
         REF      Y8
         REF      YF
         REF      Y08
         REF      Y1
         REF      Y3
         REF      X80               SET TIC
*
*        MM REFS
*
         REF      T:GBUF            TO GET A BUFFER FOR THE DCB CHECKEER
         REF      T:RBUF            TO RETURN A SPECIAL BUFFER
         REF      T:GNVNPI          TO GET DELTA'S DATA PAGE
         REF      T:RVPI            TO RELEASE DELTA'S DATA PAGE
         REF      FPMC              TO CHECK FOR FREE PAGE IN USER AREA
         REF      NPMC              TO CHECK FOR UNALLOCATED PAGE
         REF      T:SNAC            TO SET THE ACCESS CODES WHEN RESTORING
*,*                                  A SHARED PROCESSOR FOR TEL GET CAL
         REF      T:TOTESZ          TO FIND USER SIZE WHEN ASSOCIATING
*,*                                  A SHARED LIBRARY OR DELTA
         REF      T:PAC             TO LOAD ACCESS CODES FOR SP. SHARED
*,*                                  PROCESSOR AREA ON ASSOC/DISASSOC
*
*        T:OV REFS
*
         REF      DCBCHK#           TO CHECK DCBS AFTER THE TEL GET CAL
         REF      STEPOVRSEG        FOR DCBCHK#
*
*        SCHED REFS
*
         REF      T:REG             REPORT EVENT AND GIVE UP
         REF      E:AP              ASSOCIATE SHARED PROCESSOR EVENT
         REF      E:SL              SLEEP EVENT FOR M:WAIT CAL PROCESSING
         REF      TRAPEXIT          UCAL EXIT
*
*        MISC ROUTINES
*
         REF      CKLIMIT           TO CHECK MEMORY PROTECTION
         REF      T:JOBENT          PROCESS THE M:JOB CAL
         REF      T:JECLS           *JOBENT ROUTINE TO CLEANUP AND CLOSE
         REF      MTIME             PROCESS M:TIME CAL
         REF      SEGLD             PROCESS M:SEGLD CAL
         REF      MSRTFILE          PROCESS M:TFILE CAL
         REF      T:DSMT            TO DISASSOCIATE TAPES WHEN DELETING
*,*                                  A USER (CALLED BY STEP)
         REF      MSROCTY           TO OUTPUT M:KEYIN MESSAGE
         REF      MSRTYPR           TO OUTPUT M:KEYIN MESSAGE
         REF      QUEUE             IO TO OC FROM M:KEYIN
         REF      T:ABORTM          4A-00 ERR FROM M:KEYIN CAL
*
*        IORT REFS
*
         REF      CHKBIT            TO GET FIRST FPT PRESENCE WORD
         REF      CHKBIT1           TO GET SUBSEQUENT FPT WORDS
         REF      JHKBIT            CHECK FOR FPT PRESENCE BIT
         REF      JHKBIT1           CHECK FOR FPT PRESENCE BIT
         REF      IOSPIN            WAIT FOR DCB:FCN TO GO TO ZERO
         REF      MSRWRTX           NORMAL EXIT FROM M:KEYIN CAL
         REF      SAVBLK            M:KEYIN-SET BLK IN DCB
         REF      SETBTDQ1          M:KEYIN-SET HBTD IN DCB
         REF      PUSHALL           USED BY M:KEYIN LOGIC
*
*        TRAPC REFS
*
         REF      MSTRAP            PROCESS THE M:STRAP CAL
         REF      MXCON             PROCESS THE M:XCON CAL
         REF      MINT              PROCESS THE M:INT CAL
         REF      MSTIMER           PROCESS THE M:STIMER CAL
         REF      MTTIMER           PROCESS THE M:TTIMER CAL
*
*        POS REFS
*
         REF      PEOF              PROCESS M:PFIL EOF CAL
         REF      PFIL              PROCESS M:PFIL CAL
         REF      PLEOFRM           PROCESS M:PFIL EOF FOR LABELED TAPE
         REF      PRECORD           PROCESS M:PRECORD CAL
         REF      REW               PROCESS M:REW CAL
         REF      WEOF              PROCESS M:WEOF CAL
*
*        COC ROUTINE REFS
*
         REF      COCGLN            GET COC LINE # FOR CAL1,8 06XXXXXX
*
*        COC TABLE SREFS
*
         SREF     LB:UN             USER # ASSOCIATED WITH COC LINE
         SREF     LNOL              MAX # OF COC LINES
         SREF     MODE              FLAGS
         SREF     MODE2             FLAGS
         SREF     MODE3             FLAGS
         SREF     MODE4             FLAGS
         SREF     MODE4INIT         FLAGS
         SREF     MODE5             FLAGS
         SREF     MODE6             FLAGS
         SREF     MODENO            MODE
         SREF     BUFCNT            # OF BUFFERS IN USE BY LINE
         SREF     COCII             INPUT STREAM INSERTION POINTER
         SREF     COCOC             # OF CHARACTERS TO BE OUTPUT
         SREF     COCTERM           TERMINAL TYPE
         SREF     CPI               INITIAL CARRIAGE POSITION
         SREF     CPOS              CURRENT CARRIAGE POSITION
         SREF     COB:STAR          DETERMINE REQUESTED TRANSLATE TBL TYPE
         SREF     COCHTT            HIGHEST LEGAL COC TERMINAL TYPE
         SREF     COCITV            INPUT TRANSLATE TABLE POINTERS
*
*        SREFS FOR TERMINAL COUPLING FEATURE, AND TERMINAL I/O PURGE
*
         SREF     TIE               COUPLING CONTROL TABLE
         SREF     DECOUPLE%         TERMINAL DECOUPLING ROUTINE
         SREF     COCDSABL          DISABLE COC INTERRUPTS
         SREF     COCENABL          ENABLE COC INTERRUPTS
         SREF     COCPUTBL          RELEASE COC BUFFER
         SREF     KILLIN            RELEASE COC INPUT BUFFERS
         SREF     COCKO             DELETE OUTPUT BUFS FOR M:PURGE
         SREF     COCOR             COC OUTPUT REMOVAL POINT
         SREF     ESTDTX            TEXT NAME OF EBCD STANDARD TERMINAL
         SREF     EAPLTX            TEXT NAME OF EBCD APL TERMINAL
         SREF     SSTDTX            TEXT NAME OF SELECTRIC STANDARD TERMINAL
         SREF     SAPLTX            TEXT NAME OF SELECTRIC APL TERMINAL
         SREF     COCSTX0           TEXT NAME OF SPARE 0 TERMINAL
         SREF     COCSTX1           TEXT NAME OF SPARE 1 TERMINAL
         SREF     COCSTX2           TEXT NAME OF SPARE 2 TERMINAL
         SREF     COCSTX3           TEXT NAME OF SPARE 3 TERMINAL
         SREF     COCSTX4           TEXT NAME OF SPARE 4 TERMINAL
         SREF     APLTX             TEXT NAME OF ASCII APL TERMINAL
*
*        CROAK REFERENCES
*
CORATX   EQU      1                 CORE RAT INDEX
XFBFF    EQU      NB31TO0+11
X800     EQU      BT31TO0+12
X10      EQU      BT31TO0+5
X4       EQU      BT31TO0+3
M8       EQU      MASKS+8
XFF7F    EQU      NB31TO0+8         RESET TIC
         TITLE    'UCAL'
*F*
*F*      NAME:    UCAL
*F*
*F*      PURPOSE: TO TRANSFER CONTROL TO THE CALLED ROUTINE WITHIN
*F*               THE MISOV OVERLAY.
*F*
*F*      DESCRIPTION:  R0 HAS BEEN LOADED WITH AN INDEX TO THE ROUTINE
*F*               TO BE EXECUTED.  THIS INDEX IS ADDED TO AN INTERNAL
*F*               BRANCH TABLE TO OBTAIN THE ADDRESS OF THE ROUTINE
*F*               WITHIN THE OVERLAY AND TRANSFER CONTROL TO IT.
*F*
UCAL     AI,0     DRIVE
         B        *0
DRIVE    EQU      %-1
         B        MVNAMDAT
         B        T:ASSOCIATE
         B        T:DISASSOCIATE
         B        T:CHTBL
         B        T:SAVEGET
         B        T:GHOST
         B        T:WAIT
         B        MSTRAP
         B        MXCON
         B        MINT
         B        MSTIMER
         B        MTTIMER
         B        T:DSMT
         B        T:JOBENT
         B        MSRTFILE
         B        MTIME
         B        PEOF
         B        PFIL
         B        PLEOFRM
         B        PRECORD
         B        REW
         B        WEOF
         B        SEGLD
         B        T:GDDL
         B        MSRKEY
         B        T:JECLS           *CLOSE THE JOBENT STREAM FOR STEP
         RES      40
DRSZ     EQU      %-DRIVE
         PAGE                                                           01858000
*F*
*F*      NAME:    T:GDDL
*F*
*F*      PURPOSE: TO PROCESS THE M:GDDL (GET DYNAMIC DATA LIMITS) CAL.
*F*
*F*      DESCRIPTION:  (1) THE NUMBER OF PAGES A USER COULD OBTAIN BASED
*F*                        ON HIS CORE AUTHORIZATION IS COMPUTED BY SUB-
*F*                        TRACTING HIS CURRENT SIZE (LESS CONTEXT PAGES)
*F*                        FROM HIS AUTHORIZATION IN JB:MAX.
*F*
*F*                    (2) THE NUMBER OF PAGES A USER COULD OBTAINE BASED
*F*                        ON THE SWAP SIZE IS COMPUTED BY SUBTRACTING
*F*                        HIS CURRENT SIZE FROM SL:CORE.
*F*
*F*                    (3) THE NUMBER OF PAGES A USER COULD OBTAIN BASED
*F*                        ON THE CORE SIZE OF THE SYSTEM IS COMPUTED BY
*F*                        ADDING THE NUMBER OF PAGES THE USER REQUIRES
*F*                        FOR SHARED PROCESSORS TO HIS CURRENT SIZE
*F*                        AND SUBTRACTING THAT AMOUNT FROM S:PCORE.
*F*
*F*               THE SMALLEST VALUE OBTAINED FROM THE CALCULATIONS
*F*               ABOVE IS STORED IN THE USER'S SR3.
*F*
*F*               THE ADDRESS OF THE FIRST WORD IN THE USER'S DYNAMIC
*F*               DATA AREA IS STORED IN THE USER'S SR1.  THE ADDRESS OF
*F*               THE LAST WORD IN THE USER'S DYNAMIC DATA AREA IS STORED
*F*               IN THE USER'S SR2.
*F*
*D*      NAME:    T:GDDL
*D*
*D*      INPUT:   SR4 = RETURN
*D*
*D*      OUTPUT:  USER'S SR1 (IN TSTACK) - WORD ADDRESS OF WORD 0 IN THE
*D*               DYNAMIC DATA REGION (J:DLL*512)
*D*
*D*               USER'S SR2 (IN TSTACK) - WORD ADDRESS OF THE LAST WORD
*D*               IN THE DYNAMIC DATA REGION (J:DDUL*512+511)
*D*
*D*               USER'S SR3 (IN TSTACK) - THE MAXIMUM NUMBER OF PAGES
*D*               THE USER COULD OBTAIN THROUGH THE M:GP, M:GCP, AND
*D*               M:GVP CALS.  THIS VALUE DOES NOT INCLUDE THE DYNAMIC
*D*               DATA PAGES HE ALREADY HAS.
*D*
*D*      REGISTERS:  R1-R5 AND R12-R15 DESTROYED.
*D*
T:GDDL   EQU      %
         LW,R4    S:CUN             L/USER #
         LW,14    SL:CORE           INITIALIZE # PGS AVAILABLE
************************************************************************
*  ADD TO THE CURRENT SIZE THE NUMBER OF ADDITIONAL PAGES THAT COULD
*  LATER BE NEEDED FOR NON-SHARED OVERLAYS.
************************************************************************
         LB,12    UB:PCT,4          USER PROC + DATA + CONTEXT + DY DATA
         LB,13    JB:PCP            PAGE COUNT OF USERS PROCEDURE
         BEZ      GPL20             SHARED PROCESSOR RUNNING-OR NO TREE TABLE
         LI,1     1                 USER RUNNING SO FIND HIS TRUE SIZE
         LB,1     JB:PCP,1          PAGE COUNT OF DATA
         AW,13    1                 CURRENT PROCD PGS + CURRENT DATA PGS
         SW,12    13                 TAKEN OUT OF TOTAL PAGE COUNT
*                                   -NOW ADD PROCEDURE AND DATA BACK
*                                     IN BASED ON JIT LIMITS TO ALLOW
*                                     FOR POSSIBLE SEGMENT LOADING
         AW,12    J:PUL
         SW,12    J:PLL
         AW,12    J:DUL
         SW,12    J:DLL
         AI,12    2                 BECAUSE LIMITS ARE INCLUSIVE
GPL20    EQU      %
************************************************************************
*  CHECK FOR MONITOR RUNNING STATUS OR A SHARED PROCESSOR WITH
*  ALL-OF-CORE PRIVILEGE.  IF SO, DON'T CHECK FOR A VIOLATION
*  OF JB:MNPA, SB:RBMX(CORATX), OR SB:ROMX(CORATX).
************************************************************************
         LW,R1    J:RNST            L/PUF IN JIT
         AND,R1   Y003E             &MASK FOR RUN FLAGS
         BEZ      GPL40             BEZ; MONITOR RUNNING
         LB,R1    UB:APR,R4         L/APR #
         BNEZ     %+2               BNEZ; APR EXISTS
         LB,R1    UB:ASP,R4         L/ASP #
         LW,R3    Y08               L/Y08 MASK
         AND,R3   P:SA,R1           C/MASK W/P:SA
         BNEZ     GPL40             BNEZ; PROC ALLOWED ALL OF CORE
         LI,R1    BA(JB:PCC)        L/BA OF CONTEXT PG CNT IN JIT
         LB,R1    0,R1              L/CONTEXT PG CNT
         SW,12    R1                CONTEXT NOT INCLUDED IN USER PG CNT
         LI,R3    BA(JB:MNPA)       L/BA OF MAX # PGS IN JIT
         LB,13    0,R3              DEFAULT MAX # OF PGS
         BNEZ     GPL30             BNEZ; USE THIS VALUE
         LI,R2    CORATX            L/CORE RAT INDEX
         LB,13    SB:RBMX,R2        L/SYSTEM LIMIT FOR BATCH CORE
         LC       J:JIT             L/FLAGS FROM WD 0 OF JIT
         BCR,8    %+2               B/NOT ONLINE
         LB,13    SB:ROMX,R2        L/SYSTEM LIMIT FOR ONLINE CORE
GPL30    BAL,R2   GPL80             BAL/CHECK FOR NEW AVAIL LIMIT
         NOP
         AW,12    R1                ADD CONTEXT BACK IN
***********************************************************************
*  HOLD BACK FOR UNALLOCATED SPARE BUFFERS
*************************************************************************
GPL40    LB,1     JB:FBUL           NO-HOLD BACK THOSE NOT YET ALLOCATED
         AI,1     -JXBUFVP+1        MAX # FPOOLS
         LI,2     JBFBUC
         LB,2     J:JIT,2           # FPOOLS ALLOCATED
         SW,1     2                 # FPOOL LEFT TO ALLOCATE
         AW,12    1                 HOLD THEM IN RESERVE
         LI,2     X'FFFF'
         AND,2    JH:LDCF           ALLOWED SYMBIONT ACCESS
         BEZ      GPL50             NO
         LI,1     JBCBUC
         LB,1     J:JIT,1           # CPOOLS USED
         CI,1     2                 DEFAULT OR MORE
         BGE      GPL50             YES-DONT HOLD BACK ANY MORE
         AI,12    2                 HOLD BACK THOSE NOT
         SW,12    1                   NOT YET ALLOCATED
***********************************************************************
*  CHECK TO SEE IF SL:CORE IS THE CONSTRAINING FACTOR
************************************************************************
GPL50    LW,13    SL:CORE
         BAL,R2   GPL80             BAL/CHECK FOR NEW AVAIL LIMIT
         BAL,2    GPL90             CHECK FOR AJIT
************************************************************************
* USER SWAP SIZE OK-NOW CHECK FOR PCORE EXCEEDED
************************************************************************
GPL240   LH,2     UH:FLG,4
         CI,2     TIC               IS COMMAND PROCESSOR ASSOCIATED
         BAZ      GPL241            NO-SEE IF THERE IS APR
         LB,1     UB:ACP,4          GET COMMAND PROCESSOR NUMBER
         LW,3     Y4
         CW,3     P:SA,1            IS CP A SPEC. SHRD. PROC.
         BANZ     GPL250            YES-GO COMPUTE SP. SHRD. PROC. SIZE
         B        %+3               NO-CP SIZE IS INCLUDED IN STD SHRD PROC SIZE
GPL241   LB,1     UB:APR,4          STD. SHRD. PROC. #
         BEZ      GPL242            NONE-SEE IF WE SHOULD HOLD BACK FOR TEL
         AW,12    J:PUL             SIZE OF APR OR ACP(NOT SPECIAL)
         SW,12    J:PLL             FROM JIT LIMITS (ALLOWS FOR SEG LOADING)
         AI,12    1                 BECAUSE LIMITS ARE INCLUSIVE
         CI,2     TIC               DID WE JUST ADD IN ACP
         BANZ     GPL255            YES-DONT CHECK FOR TEL
*                                 GET SPECIAL SHARED PROCESSOR SIZE
*                                 LARGEST OF ACP/ASP/DB
GPL242   EQU      %
         LC       J:JIT             ON-LINE USER
         BCR,8    GPL255            NO
         LW,2     Y002              DOES ON-LINE USER WANT
         CW,2     J:TELFLGS          SPACE HELD IN RESERVE FOR TEL
         BANZ     GPL255            NO
         LB,1     UB:ACP,4          COMMAND PROCESSOR #
GPL250   LB,2     PB:PSZ,1          FIND TELS SIZE
         B        GPL256
GPL255   EQU      %                 FIND # PGS REQUIRED FOR SHARED
         LI,2     0                 NO SP. SHARED CP
GPL256   LB,1     UB:ASP,4          SP.SHARED PROC OR CORE LIBRARY
         LB,13    PB:PSZ,1          ASP SIZE
         LB,1     UB:DB,4           DEBUGGER
         CB,13    PB:PSZ,1          ASP : DB
         BGE      %+2
         LB,13    PB:PSZ,1
         CW,13    2                 ASP/DB : SP.SHARED ACP
         BGE      %+2
         LW,13    2
         AW,12    13                GREATEST POSSIBLE SIZE
         LW,13    S:PCORE
         BAL,R2   GPL80             BAL/CHECK FOR NEW AVAIL LIMIT
         BAL,2    GPL90             CHECK FOR AJIT PAGE
************************************************************************
*  CHECK TO SEE IF THE CONSTRAINT IS A LACK OF UNALLOCATED PAGES
*  IN THE DYNAMIC DATA REGION.
************************************************************************
GPL257   LW,13    J:DDUL
         SW,13    J:DDLL
         AI,13    1                 SIZE OF DYNAMIC DATA AREA
         LI,R1    BA(JB:PCDD)       L/BA OF DYN DATA PG CNT
         LB,12    0,R1              # PGS USED IN DYNAMIC DATA
         BAL,R2   GPL80             CHECK IF NEW AVAIL LIMIT
         BAL,2    GPL90             CHECK FOR AJIT PAGE
************************************************************************
*  GET THE DYNAMIC DATA REGION LIMITS AND STORE WITH
*  THE AVAILABLE PAGE COUNT INTO THE USER'S REGISTERS
*  IN TSTACK.  EXIT.
************************************************************************
         LD,D1    J:DDLL            L/DYN DATA LOWER AND UPPER LIMITS
         SLD,D1   9                 G/WORD ADDRESSES
         AI,D2    X'1FF'            G/WD ADR OF TOP OF UPPER PAGE
         LI,R1    SR1               L/DISP FROM *J:BASE TO SR1 IN TSTACK
         LCI      3                 L/CC'S FOR STM
         STM,D1   *J:BASE,R1        S/D1 - D3 INTO USER'S SR1 - SR3
GPL75    B        T:SELFDESTRUCT    RETURN
******************************************************************************
* UPDATE THE CURRENT AVAILABLE PAGE LIMIT IN R14 BY SETTING R14 TO
* THE MINIMUM OF (R13-R12) AND R14.
******************************************************************************
GPL80    SW,13    12                LIMIT-USED PGS (SAME TYPE)
         CW,13    14                NEW AVAILABLE PGS * OLD AVAILABLE PGS
         BG       1,2               NOT A NEW AVAILABLE LIMIT
         LW,14    13                SET NEW AVAILABLE PAGE LIMIT
         B        0,R2              RETURN
*****************************************************************
*  CHECK TO SEE IF HE WOULD NEED AN AJIT PAGE IF HE WERE TO
*  GET ALL OF THE PAGES HE COULD
*****************************************************************
GPL90    LW,1     J:AJ
         BNEZ     0,2               HE ALREADY HAS AN AJIT
         LW,5     14                # OF PAGES HE COULD GET
         LI,1     JBNRG
         LB,1     J:JIT,1           # OF GRAN. REMAINING
         LCW,1    1
         AW,1     5                 # PAGES
         AI,1     3                 ROUND UP
         DW,1     X4                # ADDITIONAL SEEKS REQUIRED
         AW,5     1
         SLS,5    1                 # DOUBLEWORDS REQUIRED
         AW,5     J:CLE             NW CLIST LENGTH
         CI,5     JCCL              WILL IT FIT
         BL       0,2               YES-AJIT NOT NEEDED
         AI,14    -1                TAKE OUT AJIT PAGE
         B        0,2
         PAGE
         PAGE
         BOUND    8
PROCLIMT GEN,8,24 PNAMEND,0
OLAYLIMT GEN,8,24 PPROCS,0          MAX LEGAL APO + 1
         PAGE
*F*
*F*      NAME:    T:WAIT
*F*
*F*      PURPOSE: TO PROCESS THE M:WAIT CAL.
*F*
*F*      DESCRIPTION:  THE NUMBER OF 1.2 SECOND INTERVALS TO WAIT IS
*F*               MOVED FROM THE FPT AND STORED IN THE USER'S U:MISC.
*F*               THE USER'S PROGRAM IS SUSPENDED VIA A CALL TO T:REG
*F*               WITH THE SLEEP EVENT SPECIFIED.  WHEN A WAKE-UP EVENT
*F*               IS REPORTED ON THE USER HE WILL BE REENTERED AT THE
*F*               M:WAIT CAL+1 VIA TRAPEXIT.
*F*
T:WAIT   EQU      %
         LW,1     S:CUN             GET CURRENT USER #
         AI,6     1                 ROUND UP
         AND,6    MASKS+17
*
         STW,6    U:MISC,1          SAVE WAKE UP LIMIT
*
         LI,6     E:SL              REPORT SLEEPER TO SCHEDULER
         LI,11    CC1RST            EXIT FROM REG
         B        T:REG              GIVE UP TO SCHED
         PAGE                                                           00994000
*F*
*F*      NAME:    T:CHTBL
*F*
*F*      PURPOSE: TO PROCESS CAL1,8   FPT CODE 06
*F*
*F*      DESCRIPTION:  BITS 8-11 OF FPT WORD 0 INDICATE THE TYPE
*F*                    OF CAL AS FOLLOWS:
*F*
*F*                  0 - CHANGE TERMINAL TYPE
*F*                  1 - RESET BREAK COUNT
*F*                  2 - CHANGE TERMINAL MODE
*F*                  4 - OBTAIN TERMINAL STATUS
*F*                  6 - EXTENDED OBTAIN TERMINAL STATUS
*F*                  7 - PURGE INPUT/OUTPUT BUFFERS
*F*                  8 - CHANGE ACTIVATION CHARACTER
*F*                  B - 2ND EXTENSION OF OBTAIN TERMINAL STATUS
*F*
*F*               T:CHTBL DRIVES TO THE APPROPRIATE ROUTINE TO PROCESS
*F*               THE CAL.
*F*
*F*      REFERENCE:  T:CT, T:CAC, T:TS, SETMOD, AND RSTBRK 'F' REPORTS.
*F*
T:CHTBL  EQU      %
         BAL,R5   COCGLN            GET COC LINE NUMBER
         B        CC1SET            B/NOT ONLINE USER, OR .FF LINE #
         LW,R1    R2                SHUFFLE REGISTERS
         LW,R0    R7                SAVE FPT+1 ADR FOR SETMOD
         LH,R7    R6
         LH,R5    R6                L/LH OF WD 0 OF FPT
         SLS,R5   -4                RJ/BITS 8 -> 11 OF FPT
         AND,R5   MASKS+4           &/BITS 8 -> 11 W/.F
         LH,R4    C1806TV,R5        L/DISPLACEMENT TO ROUTINE
         B        UCAL:,R4          B TO APPROPOS ROUTINE
*
C1806    COM,16   AF-UCAL:
*
C1806TV  C1806    T:CT              0 - CHANGE TERMINAL TYPE
         C1806    RSTBRK            1 - RESET BREAK COUNT
         C1806    SETMOD            2 - SET TERMINAL MODE
         C1806    CC1SET            3 - ILLEGAL
         C1806    T:TS              4 - OBTAIN TERMINAL STATUS
         C1806    CC1SET            5 - ILLEGAL
         C1806    T:TS              6 - OBTAIN TERMINAL STATUS (EXTENDED)
         C1806    T:PURGET          7 - PURGE INPUT/OUTPUT BUFFERS
         C1806    T:CAC             8 - CHANGE ACTIVATION CHARACTER SET
         C1806    CC1SET            9 - ILLEGAL
         C1806    CC1SET            A - ILLEGAL
         C1806    T:TS              B - OBTAIN TERMINAL STATUS (2ND EXTENSION)
         C1806    CC1SET            C - ILLEGAL
         C1806    CC1SET            D - ILLEGAL
         C1806    CC1SET            E - ILLEGAL
         C1806    CC1SET            F - ILLEGAL
         PAGE
*F*
*F*      NAME:    T:CT
*F*      PURPOSE: TO PROCESS THE T:CT CAL
*F*
*F*      DESCRIPTION:  THE M:CT CAL ALLOWS A USER TO SWITCH AMONG THE
*F*               TERMINAL TRANSLATION TABLES PROVIDED BY THE COC I/O
*F*               ROUTINES.
*F*
*F*      REFERENCE: CP-V TIME SHARING REFERENCE MANUAL
*F*
*D*      NAME:    T:CT
*D*
*D*      INPUT:   R0 = WA(FPT+1)
*D*               R6 = FPT WORD 0
*D*               R2 = LINE NUMBER
*D*
*D*      DESCRIPTION:  WORD 0 OF THE FPT CONTAINS THE SETTING FOR
*D*               COCTERM.
*D*
T:CT     EQU      %
         LI,R10   CC1RST            L/EXIT ADR
T:CT10   CW,R6    BT31TO0+31        C/FPT WORD W/.40000000
         BANZ     T:CT14            BANZ; ASSUME TEXT FORMAT
         AI,R6    0                 +0 TO FPT WORD
         BGE      T:CT19            BGE; NOT INDIRECT
         CI,R6    X'1FFF0'          C/FPT WD 0 W/.1FFF0
         BANZ     %+2               BANZ; NOT IN REGS
         AW,R6    J:BASE            + ADR OF R0 IN TSTACK
         LW,R6    0,R6              L/INDIRECT WORD
         CW,R6    BT31TO0+31        C/FPT INDIRECT WORD W/.40000000
         BAZ      T:CT19            BAZ/NOT TEXT
T:CT14   LI,R1    COCHTT            L/HIGHEST LEGAL TERM TYPE INDEX
T:CT15   CW,R6    TERMTX,R1         C/TEXT W/TABLE
         BE       T:CT18            B/FOUND MATCH
         AI,R1    -1                DEC INDEX
         BGE      T:CT15            B/MORE TO CHECK
         B        CC1SET            B/NOT FOUND; ILLEGAL
T:CT18   LW,R6    R1                L/INDEX OF TERM TYPE
T:CT19   AND,R6   M8                &/INDEX W/.FF; STRIP ANY GARBAGE
         CI,R6    COCHTT            C/REQUESTED TYPE W/HIGHEST LEGAL
         BG       CC1SET            BG; ILLEGAL, TAKE ERROR RETURN
         LW,R5    R6                L/REQUESTED TERMINAL TYPE
         SLS,R5   -1                SHIFT TO GET 'STARS' INDEX
         LC       MODE2,R2
         BCS,1    T:CT40            B/2741 LINE
         MTB,0    COB:STAR,R5       CHECK 'STAR' TABLE IN COC HANDLER
         BNEZ     CC1SET            B/HE'S A TTY AND REQUESTED A 2741 TBL
T:CT20   LH,R5    COCITV,R6         L/INPUT TRANS TABLE ADR
         BEZ      CC1SET            BEZ; TABLE DOESN'T EXIST
         STB,R6   COCTERM,R2        S/REQUESTED TERMINAL TYPE
         B        *R10              RETURN TO CALLER
*D*
*D*               IF THE USER IS ATTEMPTING TO CHANGE THE TERMINAL
*D*               TYPE FROM 2741 TO TTY, OR FROM TTY TO 2741, HE IS
*D*               RE-ENTERED WITH CC1 SET.
*D*
T:CT40   MTB,0    COB:STAR,R5       CHECK 'STAR' TABLE IN COC HANDLER
         BEZ      CC1SET            B/HE'S A 2741 AND REQUESTED TTY TBL
         AND,R6   NB31TO0+1         &/TYPE W/.FFFFFFFE; MAKE EVEN
         B        T:CT20            B; SET TYPE
*
*  TERMTX, INDEXED BY COCTERM, YIELDS THE TEXT EQUIVALENT
*  OF THE TERMINAL TYPE
*
TERMTX   TEXT     '33  '            TTY 33
         TEXT     '35  '            TTY 35
         TEXT     '37  '            TTY 37
         TEXT     '7015'            XEROX 7015
         DATA     ESTDTX,ESTDTX     EBCD STANDARD
         DATA     EAPLTX,EAPLTX     EBCD APL
         DATA     SSTDTX,SSTDTX     SELECTRIC STANDARD
         DATA     SAPLTX,SAPLTX     SELECTRIC APL
         DATA     COCSTX0           SPARE 0
         DATA     COCSTX1           SPARE 1
         DATA     COCSTX2           SPARE 2
         DATA     COCSTX3           SPARE 3
         DATA     COCSTX4           SPARE 4
         DATA     APLTX             ASCII APL
         PAGE
*F*
*F*      NAME:    T:CAC
*F*
*F*      PURPOSE: TO PROCESS THE CHANGE ACTIVATION CHARACTER CAL.
*F*
*F*      DESCRIPTION:  THE CHANGE ACTIVATION CHARACTER CAL ALLOWS THE
*F*               USER TO CHOOSE AMONG FOUR SETS OF MESSAGE-TERMINATION,
*F*               OR ACTIVATION, CHARACTERS FOR TERMINAL INPUT.
*F*
*F*               IN ADDITION TO THE NORMAL SET OF ACTIVATION CHARACTERS,
*F*               THREE ADDITIONAL SETS ARE AVAILABLE.  THEY ARE (1) ALL
*F*               SPECIAL GRAPHICS AND CONTROL CHARACTERS,  (2) ALL
*F*               CONTROL CHARACTERS, AND (3) DELTA ACTIVATION AND NO
*F*               PROMPTING.
*F*
*F*      REFERENCE:  CP-V TIME SHARING REFERENCE MANUAL.
*F*
*F*
*D*      NAME:    T:CAC
*D*
*D*      INPUT:   R0 = WA(FPT+1)
*D*               R1 = LINE NUMBER
*D*               R6 = FPT WORD 0
*D*                     BIT 14 SET INDICATES TTY CONTROL CHARACTERS
*D*                     BIT 15 SET INDICATES TTY CONTROL CHARACTERS AND
*D*                        SPECIAL GRAPHICS
*D*               R7 = FPT WORD 0, BITS 0-15 (RIGHT JUSTIFIED)
*D*
*D*      DESCRIPTION:  BITS 6-7 OF THE COC TABLE 'MODE2', THE
*D*               ACTIVATION CHARACTER SET, ARE RESET AS SPECIFIED IN
*D*               BITS 14-15 OF WORD 0 OF THE FPT.
*D*
T:CAC    AND,R7   MASKS+2           GET BITS 14-15
         DISABLE
         LB,R0    MODE2,R2          GET CURRENT SETTING
         AND,R0   XFC               CLEAR OLD SETTING
         OR,R0    R7                REPLACE
         STB,R0   MODE2,R2
ENCC1    ENABLE
         B        CC1RST            EXIT
         PAGE
*F*
*F*      NAME:    T:TS
*F*
*F*      PURPOSE: TO PROCESS THE OBTAIN TERMINAL STATUS CAL.
*F*
*F*      DESCRIPTION:  THE OBTAIN TERMINAL STATUS CAL PROVIDES AN ON-LINE
*F*               USER WITH THE CURRENT STATUS OF DATA USED BY THE COC
*F*               I/O ROUTINES TO CONTROL THE FUNCTIONAL CHARACTERISTICS
*F*               OF THE TERMINAL.
*F*
*F*               TWO FORMS OF THE CAL ARE AVAILABLE, THE SECOND ONE
*F*               PROVIDING MORE INFORMATION THAN THE FIRST.
*F*
*F*      REFERENCE:  CP-V TIME SHARING REFERENCE MANUAL
*F*
*F*
*D*      NAME:    T:TS
*D*
*D*      INPUT:   R0 = WA(FPT+1)
*D*               R2 = LINE NUMBER
*D*               R6 = FPT WORD 0
*D*               R7 = FPT WORD 0, BITS 0-15 (RIGHT JUSTIFIED)
*D*
*D*      OUTPUT:  IN USER'S TSTACK:
*DO*
*D*
*                 *************************************
*     USER'S R8   *COCTERM *  MODE  * MODE2  * MODE3  *
*                 *************************************
*
*                 *************************************
*     USER'S R9   *  CPOS  * COCOC  * BUFCNT * LB:UN  *
*                 *************************************
*
*     THE FOLLOWING TWO REGISTERS ARE SET ONLY FOR 06400000
*     AND 06B00000.
*
*                 *************************************
*     USER'S R10  * MODE4  *  CPI   *       I*  TIE   *
*                 *************************************
*
*                 *************************************
*     USER'S R11  * MODE5  * MODE6  *PLATEN W*  LPP   *
*                 *************************************
*
*                 I = 1 IF INPUT BUFFERS EXIST
*                 W = WIDTH, LPP = LINES/PAGE
*
*     THE FOLLOWING REGISTERS ARE SET ONLY FOR 06B00000.
*
*                 *************************************
*     USER'S R12  * TEXT EQUIVALENT OF TERMINAL NAME  *
*                 *************************************
*
*                 *************************************
*     USER'S R13  *MODE4INIT*COCOPT2*                 *
*                 *************************************
*
*FIN*
*D*
*D*      REGISTERS:  R3, R4, R5 AND R15 DESTROYED
*D*
*D*      DESCRIPTION: IF BITS 8-11 OF THE FPT WORD 0 = 0100, THE
*D*               OLD FORM OF THE FPT IS SPECIFIED AND THE USER'S
*D*               REGISTERS 8 AND 9 ARE LOADED WITH TERMINAL STATUS
*D*               INFORMATION DEFINED ABOVE.
*D*
*D*               IF BITS 8-11 OF THE FPT WORD 0 = 0110, THE EXTENDED
*D*               FORM OF THE FPT IS SPECIFIED AND THE USER'S REGISTERS
*D*               8 THROUGH 11 ARE LOADED WITH THE TERMINAL STATUS
*D*               INFORMATION DEFINED ABOVE.
*D*
T:TS     EQU      %
         LB,R5    TSBC-1,R5         L/# OF BYTES TO MODE
TS050    LI,R4    R8*4              L/BTD FROM R0 TO R8
TS100    LH,R3    ADRS-(R8*2),R4    L/DISPLACEMENT TO DESIRED VALUE
*                                   .. IN MONITOR OR JIT
         BGEZ     TS150             BGEZ; DISPLACEMENT IS ADR IN ROOT
         LB,R15   J:JIT+X'200',R3   L/VALUE FROM JIT
         B        TS200             B
TS150    LB,R15   *R3,R2            L/VALUE FROM ROOT
TS200    STB,R15  *J:BASE,R4        S/VALUE IN USER'S REGISTER IN TSTACK
         AI,R4    1                 +1 TO TABLE AND OUTPUT INDEX
         BDR,R5   TS100             BDR; GET NEXT VALUE
         LI,R4    R9*4+1            L/BTD TO BYTE 1 OF R9 (COCOC)
         LH,R15   COCOC,R2          L/COCOC; OUTPUT CHARACTER COUNT
         CI,R15   X'FF'             C/COCOC W/.FF
         BLE      %+2               BLE; WILL FIT INTO BYTE
         LI,R15   X'FF'             L/.FF; COCOC > .FF, USE .FF
         STB,R15  *J:BASE,R4        S/'COCOC' INTO USER'S R9, BYTE 1
         CI,R7    X'20'             C/LH OF FPT W/.20
         BAZ      TS250             B/OLD FORMAT
         LI,R4    R10*4+2           L/BTD TO BYTE 2 OF R10
         LH,R15   COCII,R2          L/INPUT INSERTION POINTER
         BEZ      %+2               BEZ; NO INPUT EXISTS
         LI,R5    1                 L/1; FLAG INDICATING INPUT EXISTS
         STB,R5   *J:BASE,R4        S/FLAG (0 OR 1)
TS250    CI,R7    X'10'             C/BITS 8 -> 11 OF FPT W/.10
         BAZ      TS500             BAZ; NOT 2ND EXTENDED FORMAT
         LB,R5    COCTERM,R2        L/TERMINAL TYPE
         LW,R5    TERMTX,R5         L/TEXT EQUIVALENT OF TERM TYPE
         LI,R4    R12               L/DISPLACEMENT TO R12 FROM J:BASE
         STW,R5   *J:BASE,R4        S/TEXT IN R12 IN TSTACK
TS500    B        CC1RST            B; DONE, RESET CC1, EXIT
         SPACE    1
********************************************************************************
*  EACH OF THE FOLLOWING TABLE'S ENTRIES ARE IN ONE OF THE
*  FOLLOWING FORMATS:
*  1  IF THE ENTRY POINTS TO A LINE-NUMBER INDEXED TABLE IN
*     THE ROOT, THE ENTRY IS THE WORD ADDRESS OF THAT TABLE.
*  2  IF THE ENTRY POINTS TO A BYTE IN THE JIT, THE ENTRY
*     IS BA(JIT BYTE)-BA(J:JIT+X'200').
*  3  IF A DUMMY ENTRY, A 0 IS USED.
*  THERE IS A 1-TO-1 CORRESPONDENCE BETWEEN THIS TABLE AND THE
*  OUTPUT BYTES IN THE USER'S REGISTERS IN TSTACK (STARTING
*  WITH R8).
********************************************************************************
ADRS     EQU      %
         DATA,2   COCTERM,MODE,MODE2,MODE3,CPOS,COCOC,BUFCNT,LB:UN
         DATA,2   MODE4,CPI,,TIE,MODE5,MODE6
         DATA,2   BA(JB:PCW)-BA(J:JIT+X'200')    PLATEN WIDTH
         DATA,2   BA(JB:LPP)-BA(J:JIT+X'200')    LINES/PAGE
         DATA,2   0,0,0,0           SKIP TERM TYPE TEXT ENTRY
         DATA,2   MODE4INIT
         DATA,2   BA(JB:COCOPT2)-BA(J:JIT+X'200')  JB:COCOPT2
         BOUND    4
TSBC     DATA,1   8,0               M:TS (4), DUMMY
         DATA,1   16,0,0,0,0        M:TS2 (6), DUMMIES
         DATA,1   22                M:TS3 (.B)
         BOUND    4
         PAGE
*F*
*F*      NAME:    SETMOD
*F*
*F*      PURPOSE: TO PROCESS THE CHANGE TERMINAL MODE CAL.
*F*
*F*      DESCRIPTION:  THIS CAL ALLOWS THE ON-LINE USER TO CONTROL
*F*               CERTAIN TERMINAL ATTRIBUTES AS DEFINED BY THE COC
*F*               TABLES: MODE, MODE2, MODE3, AND MODE4 AND AS
*F*               DEFINED BY THE VALUES IN JB:PCW (PLATEN WIDTH) AND
*F*               JB:LPP (LINES PER PAGE) IN THE USER'S JIT.
*F*
*F*      REFERENCE:  CP-V DATA BASE TECHNICAL MANUAL (COC TABLES)
*F*                  CP-V TIME SHARING REFERENCE MANUAL
*F*
*D*      NAME:    SETMOD
*D*
*D*      INPUT:   R0 = WA(FPT+1)
*D*               R1 = LINE NUMBER
*D*               R6 = FPT WORD 0
*D*               R7 = FPT WORD 0, BITS 0-15 (RIGHT JUSTIFIED)
*D*
SETMOD   EQU      %
         LW,4     1                 GET LINE # OF CURRENT USER
         LI,5     0
         LB,9     MODE2,4           CHECK FOR 2741 OR TTY
         AND,9    X10
         SLS,9    -3                TTY=0, 2741=2
         AI,9     MSK               POINT TO CORRECT SET OF MASKS
         LW,R7    S:CUN             L/CURRENT USER #
         LH,R7    UH:FLG,R7         L/UH:FLG; USER FLAGS
         CI,R7    SJAC              C/FLAGS W/SPECIAL-JIT-ACCESS FLAG
         BAZ      %+2               BAZ; NOT SJAC
         AI,R9    4                 +4 TO USER-CHANGABLE BIT MASK POINTER
         LW,7     0
         AI,7     -1                GET FPT ADR FOR JHKBIT
         BAL,1    JHKBIT1           CHECK FOR MODE
         B        STMD              GOT IT
         AI,5     1                 BUMP MODE TABLE POINTER
         BAL,1    JHKBIT            CHECK FOR MODE2
         B        STMD              GOT IT
         AI,5     1
         BAL,1    JHKBIT            CHECK FOR MODE3
         B        STMD
         LI,5     BA(JB:PCW)        L/BA OF PLATEN WIDTH IN JIT
         BAL,1    JHKBIT            CHECK P BIT FOR PCW, GET VALUE IN R2
         STB,2    0,5               SET PLATEN WIDTH
         LI,5     BA(JB:LPP)        L/BA OF LINES PER PAGE IN JIT
         BAL,1    JHKBIT            CHECK P BIT FOR LPP, GET VALUE IN R2
         STB,2    0,5               SET LINES/PAGE
         LI,R5    3                 L/3; INDEX TO MODE4 IN MODENO & MSK
         BAL,R1   JHKBIT            CHECK P BIT FOR MODE4
         B        STMD              B; SET MODE4
         SLS,R14  1                 SHIFT PRESENCE BITS FROM FPT
         BEV      SETTTR            BEZ; TERM TYPE NOT SPECIFIED
         LW,R6    0,R7              L/WORD OF FPT
         AI,R7    1                 INC FPT POINTER
         BAL,R5   COCGLN            BAL/GET COC LINE NUMBER
         DATA     0                 LINE NUMBER CHANGED IN THE LAST MILLISEC
         BAL,R10  T:CT10            BAL/CHANGE TERMINAL TYPE
SETTTR   LI,R5    4                 L/INDEX FOR MODE5
         BAL,R1   JHKBIT            CHECK P BIT FOR MODE5
         B        STMD              B; SET MODE5
         LI,R5    5                 L/INDEX FOR MODE6
         BAL,R1   JHKBIT            CHECK P BIT FOR MODE6
         B        STMD              B; SET MODE6
         LI,R5    BA(JB:COCOPT2)    L/BA OF SPECIAL COC OPTIONS IN JIT
         BAL,R1   JHKBIT            CHECK P BIT FOR SPEC OPTIONS
         STB,R2   0,R5              S/SPECIAL COC OPTIONS
         B        CC1RST            DONE EXIT TO CAL+1
*
STMD     EQU      %                 JHKBIT RETURNS FPT DATA WORD IN R2
         INT,12   2                 L/NEW VALUES IN R12, MASK IN R13
         LB,11    *9,5              L/USER-CHANGABLE BITS
         AND,13   11                &USERS MASK W/USER-CHANGABLE BITS
         LH,R2    MODENO,R5
         CI,R2    MODE4
         BNE      STMD3             NOT CHANGING MODE4.
         CI,13    X'C0'
         BAZ      STMD3             NOT AFFECTING COUPLE BITS.
         LI,10    TIE               TIE IS A SREF- DOES IT EXIST??
         BE       STMD3             B/NOPE, YOU CAN DO WHAT YOU WANT.
         DISABLE
         LB,10    MODE4,4           LOOK AT COUPLE BITS
         CI,10    X'80'             IS COUPLE ENABLED???
         BANZ     %+5               B/YES.
         AND,10   MASKS+7           IF NOT, TURN OFF THE
         STB,10   MODE4,4           COUPLE BITS AND
         STB,4    TIE,4             RESET TIE.
         B        STMD2
         ENABLE
         CI,13    X'80'             WHEN COUPLE IS SET, YOU CAN
         BAZ      STMD2             ONLY RESET BITS.
         CI,12    X'80'             SET THE COUPLE BIT
         BANZ     1,1               -NOP IF COUPLE ALREADY SET.
         LCI      0
         PSM,0    TSTACK            REJECT COUPLE WHILE COUPLE SET
         LW,2     4                 CAUSES AN IMPLICIT DECOUPLE
         BAL,SR4  DECOUPLE%         BEFORE CLEARING COUPLE
         LCI      0                 PERMISSION.
         PLM,0    TSTACK
         B        STMD3
STMD2    CI,13    X'40'             DIDDLING REJECTED BIT????
         BAZ      %+3               NOPE.
         CI,12    X'40'             TRYING TO SET IT???
         BANZ     1,1               YOU CANT DO THAT.....
STMD3    EQU      %                 A CAN OF WORMS........
         DISABLE                    DIS-ALLOW INTERRUPTS
         LB,10    *2,4              L/CURRENT MODEX
         STS,12   10                G/NEW VALUE
         STB,10   *2,4              S/NEW VALUE IN MODEX
         ENABLE
         B        1,1               EXIT TO BAL PLUS 2
*
* PERMISSION BYTE MASKS FOR ALTERING MODE TABLES.
* IF BIT IS SET THE USER IS PERMITTED TO ALTER THE
* CORRESPONDING BITS IN THE CORRESPONDING MODE TABLE.
* CP-CHANGABLE BITS ARE A SUPERSET OF USER-CHANGABLE BITS; THE
* ADDITIONAL BITS CAN BE MODIFIED ONLY BY SPECIAL-JIT-ACCESS USERS.
MSK      EQU      %
         DATA     X'8F6FE0DF'       USER-CHANGABLE BITS FOR TTY
         DATA     X'20020000'
         DATA     X'0F6FE01F'       USER-CHANGABLE BITS FOR 2741
         DATA     X'20020000'
*
         DATA     X'8FEFE0DF'       CP-CHANGABLE BITS FOR TTY
         DATA     X'20020000'
         DATA     X'0FEFE01F'       CP-CHANGABLE BITS FOR 2741
         DATA     X'20020000'
*
         PAGE
*F*
*F*      NAME:    RSTBRK
*F*
*F*      PURPOSE: TO PROCESS THE RESET BREAK COUNT CAL
*F*
*F*      DESCRIPTION:  THE BREAK COUNT, AS SPECIFIED IN THE COC
*F*               TABLE, MODE, IS RESET AND CONTROL RETURNS TO THE USER
*F*
RSTBRK   EQU      %                 RESET BREAK COUNT
         DISABLE
         LB,R0    MODE,R2           L/MODE
         AND,R0   XFC               &/MODE W/.FC; RESET BREAK COUNT
         STB,R0   MODE,R2           S/MODE
         B        ENCC1             TO CAL+1,ENABLE & WITH CC1=1
         PAGE
*
*        M:PURGE CAL ROUTINE
*
*        TO PURGE PENDING TERMINAL I/O, ISSUE M:PURGE
*
*        CAL1,8   FPT
*
*        FPT      GEN,8,4,18,1,1 6,7,0,W,R
*
*        WHERE W=1 TO PURGE OUTPUT, R=1 TO PURGE READ AHEAD.
*
T:PURGET PUSH     (R6,R11)          PUSH R6 -> R11
         BAL,13   COCDSABL          DONT BOTHER ME FOR A WHILE
         CI,6     2                 IS THE W BIT SET?
         BAZ      T:PURGE1          NOPE. DONT PURGE OUTPUT.
         LW,R1    R6                SAVE R6 FLAGS
         BAL,R13  COCKO             BAL/DELETE OUTPUT BUFS
T:PURGE1 CI,R1    1                 C/FLAGS W/1
         BAZ      %+2               NOPE.
         BAL,9    KILLIN            GO KILL INPUT.
         BAL,13   COCENABL          WAKE UP COC
         PULL     6,6
         B        CC1RST
         PAGE
*F*
*F*      NAME:    T:ASSOCIATE
*F*
*F*      PURPOSE: TO PROCESS THE ASSOCIATE SHARED PROCESSOR CAL
*F*
*F*      DESCRIPTION:  THE ASSOCIATE PROCESSOR AND DISASSOCIATE PROCESSOR
*F*               CALS ARE USED TO ASSOCIATE OR DISASSOCIATE A CORE
*F*               LIBRARY OR A DEBUGGER (DELTA IS THE ONLY DEBUGGER)
*F*               WITH A USER.  BOTH CORE LIBRARIES AND DELTA ARE
*F*               SPECIAL SHARED PROCESSORS AND RESIDE IN THE SAME
*F*               VIRTUAL AREA ABOVE X'1C000'.
*F*
*F*               TWO PROCESSOR TABLES MUST BE UPDATED WHEN A USER
*F*               ASSOCIATES OR DISASSOCIATES HIMSELF WITH A SHARED
*F*               PROCESSOR; PB:UC (USERS IN CORE ASSOCIATED WITH THE
*F*               PROCESSOR) AND PB:REP (TOTAL NUMBER OF USERS ASSOCIATED
*F*               WITH THE PROCESSOR).
*F*
*F*               ALTHOUGH BOTH A LIBRARY AND A DEBUGGER RESIDE IN THE
*F*               SAME VIRTUAL OF CORE, BOTH MAY BE ASSOCIATED WITH A
*F*               USER AT THE SAME TIME.  THIS IS POSSIBLE THROUGH THE
*F*               USE OF (1) THE BITS IN UH:FLG THAT INDICATE 'DELTA
*F*               ASSOCIATED' (DELA) AND 'DELTA IN CONTROL' (DIC), AND
*F*               (2) THE USER TABLES UB:ASP (ASSOCIATED SPECIAL PROCESSSOR,
*F*               I.E. CORE LIBRARY) AND UB:DB (ASSOCIATED DEBUGGER; I.E.
*F*               DELTA).
*F*
*F*               THE NUMBER OF USERS IN CORE (PB:UC) ASSOCIATED WITH
*F*               DELTA INCLUDES THIS USER ONLY WHEN DELTA IS IN CONTROL
*F*               (DELA AND DIC BITS BOTH SET IN UH:FLG) AND DELTA IS
*F*               IS MAPPED INTO THE USER'S VIRTUAL AREA ABOVE X'1C000'.
*F*               PB:UC FOR THE CORE LIBRARY INCLUDES THIS USER ONLY
*F*               WHEN THE USER PROGRAM IS IN EXECUTION (DELA SET; DIC
*F*               RESET) AND THE CORE LIBRARY IS MAPPED INTO THE USER'S
*F*               VIRTUAL AREA ABOVE X'1C000'.
*F*
*F*               WHEN A USER IS ASSOCIATED WITH DELTA, AND NOT
*F*               ASSOCIATED WITH A CORE LIBRARY, DELTA'S PB:UC
*F*               WILL INCLUDE THIS USER WHEN EITHER DELTA IS IN
*F*               CONTROL (DELA AND DIC BOTH SET) OF THE USER IS
*F*               IN EXECUTION (DELA SET; DIC RESET).
*F*
*F*               T:ASSOCIATE VALIDATES THAT IT IS LEGAL TO ASSOCIATE
*F*               THE REQUESTED PROCESSOR.  PB:UC AND PB:REP ARE
*F*               ADJUSTED AS EXPLAINED ABOVE.  THE PROCESSOR IS
*F*               ASSOCIATED BY REG'ING THE USER WITH THE ASSOCIATE
*F*               PROCESSOR EVENT SPECIFIED.
*F*
*D*      NAME:    T:ASSOCIATE
*D*
*D*      DATA:    FPT, WORD 0   = GEN,8,7,17 CODE,BREAK,ADDRESS
*D*                               WHERE CODE = 04
*D*                                     BREAK = 1 IF DELTA IS TO BE ENTERED
*D*                                     ADDR = ADDRESS TO ENTER DELTA
*D*
*D*               FPT, WORD 1-2 = TEXTC PROCESSOR NAME
*D*
*D*      INPUT:   R6 = 1ST WORD OF THE FPT
*D*               R7 = WA(FPT+1)
*D*
*D*      INTERFACE: T:GNVNPI, T:TOTESZ, T:PAC, T:REG
*D*
*D*      DESCRIPTION:  THE P:NAME TABLE IS SEARCHED FOR THE PROCESSOR
*D*               SPECIFIED IN THE FPT.  IF NOT FOUND, CONTROL RETURNS
*D*               TO THE USER WITH CC1 SET.
*D*
T:ASSOCIATE EQU   %
         LI,1     0                 FOR CONDITION CODES
         BAL,0    GETNAME           R5 = PROCESSOR NAME
*D*
*D*               IF THE PROCESSOR SPECIFIED IS NOT A CORE LIBRARY OR
*D*               A DEBUGGER, CONTROL RETURNS TO THE USER WITH CC1 SET.
*D*               UNLESS THIS IS CCI ASSOCIATING TEL THEN TEL
*D*               IS HANDLED LIKE A LIBRARY.
*D*
         BAL,0    GETTYPE           R2 = 1 IF LIB.   R2 = 2 IF DEBUGGER
*D*
*D*               IF THE USER IS RUNNING IN THE EXTENDED MEMORY MODE,
*D*               CONTROL RETURNS TO THE USER WITH CC4 SET.
*D*
         LW,7     J:EUP             INITIAL PAGE
         CI,7     JEUPVP            CANT ASSOCIATE IF HE IS
         BNE      CC4SET             USING EXTENDED CORE
*D*
*D*               IF THE USER IS ATTEMPTING TO ASSOCIATE A CORE
*D*               LIBRARY THAT IS CURRENTLY ASSOCIATED, CONTROL
*D*               SIMPLY RETURNS TO THE USER WITH ALL CC RESET.
*D*
*D*               IF ATTEMPTING TO ASSOCIATE A DEBUGGER THAT IS
*D*               CURRENTLY ASSOCIATED, CONTROL TRANSFERS TO 'CHKDEL'
*D*               FOR SPECIAL PROCESSING.
*D*
         EXU      TESTIT,2          R3 = LIB/DB NOW ASSOCIATED
         CW,3     5                 IS IT THE SAME
         BNE      ASSOC2            NO
         CI,2     2                 YES-IS IT DELTA
         BNE      CC0RST            NO-ASSOC SAME LIBR IS NOP
         PUSH     1                 SAVE CC=0
         B        CHKDEL            RE-ASSOCIATE DELTA
*D*
*D*               IF A CORE LIBRARY THAT IS BIASED OVER DELTA'S DATA
*D*               PAGE IS BEING ASSOCIATED WITH A USER RUNNING UNDER
*D*               DELTA, CONTROL RETURNS TO THE USER WITH CC4 SET.
*D*
ASSOC2   EQU      %
         CI,2     2                 ASSOCIATING DELTA
         BE       ASSOC3            YES
         LB,7     UB:DB,4
         BEZ      NOPAGE            DELTA NOT ASSOCIATED
         LB,7     PB:PVA,7          DELTA'S PROCEDURE BIAS
         CB,7     PB:PVA,5            : LIBRARY'S PROCEDURE BIAS
         BG       CC4SET            OVERLAP--ERROR
         B        NOPAGE            OK
*D*
*D*               IF A USER OTHER THAN AN ON-LINE USER IS ATTEMPTING TO
*D*               ASSOCIATE DELTA, CONTROL RETURNS TO THE USER
*D*               WITH CC1 SET.
*D*
*D*
*D*               IF DELTA IS TO BE ASSOCIATED WITH A USER WHO IS
*D*               RUNNING WITH A CORE LIBRARY THAT IS BIASED OVER
*D*               DELTA'S DATA PAGE, CONTROL RETURNS TO THE USER
*D*               WITH CC4 SET.
*D*
*D*               IF DELTA IS BEING ASSOCIATED THE PAGE ABOVE J:EUP
*D*               (END USER PAGE) IS OBTAINED FOR DELTA'S DELTA PAGE.
*D*               THE T:GNVNPI (GET N VIRTUAL, NO PHYSICAL) ROUTINE
*D*               IN MM IS USED TO OBTAIN THE PAGE.  THIS INSURES
*D*               SUFFICIENT PHYSICAL CORE FOR THE PAGE AND KEYS THE
*D*               SWAPPER TO PUT INITIAL DATA IN THE PAGE WHEN DELTA
*D*               IS ASSOCIATED.  IF THE USER ALREADY HAS THE PAGE,
*D*               I.E. DELTA WAS PREVIOUSLY ASSOCIATED, THIS CALL
*D*               TO T:GNVNPI IS A NOP.  IF THE PAGE IS NOT AVAILABLE
*D*               CONTROL RETURNS TO THE USER WITH CC4 SET.
*D*
ASSOC3   EQU      %                 ASSOCIATIING DELTA
         AI,7     1                 DELTA'S DATA PAGE
         MTW,0    J:JIT             BATCH OR GHOST
         BGEZ     CC1SET            YES-ONLY ONLINE CAN ASSOC DEBUGGER
         PUSH     7,1
         LB,6     UB:ASP,4
         BEZ      ASSOC4            LIBRARY NOT ASSOCIATED
         LB,6     PB:PVA,6          LIBRARY PROCEDURE BIAS
         CB,6     PB:PVA,5            : DELTA'S PROCEDURE BIAS
         BL       NOPCORE           OVERLAP--FIX STACK AND ERR
ASSOC4   LI,6     1                 GET DELTA'S DATA PAGE
         BAL,11   T:GNVNPI
         PULL     7,1
         LOAD,0   JX:CMAP,7
         CI,0     FPMC
         BE       CC4SET            NO PAGE AVAILABLE
*D*
*D*               IF A LIBRARY MUST BE DISASSOCIATED IN ORDER TO
*D*               ASSOCIATE A NEW LIBRARY A FLAG IS SET SO CONTROL
*D*               WILL RETURN TO THE USER WITH CC3 SET.
*D*
NOPAGE   EXU      TESTIT,2          R3 = OLD ASP/DB (FOR SAME TYPE)
         BEZ      %+2               NONE OF SAME TYPE CURRENTLY ASSOC.
         LI,1     -1                INDICATE ABNORMAL
*D*
*D*               THE PROCESSOR NUMBER OF ANY CURRENTLY ASSOCIATED
*D*               CORE LIBRARY (OR IF NO LIBRARY, OF THE CURRENTLY
*D*               ASSOCIATED DEBUGGER, IF ANY) IS REMEMBERED SO WE
*D*               CAN CORRECTLY ADJUST PB:UC AND PB:REP IF ASSOCIATION
*D*               OF THE REQUESTED PROCESSOR PASSES THE T:TOTESZ
*D*               (TOTAL USER SIZE) TEST.
*D*
         LB,7     UB:ASP,4          CURRENT LIBRARY
         BNEZ     %+2                IF THERE IS ONE
         LB,7     UB:DB,4           ELSE CURRENT DEBUGGER
*D*
*D*               THE PROCESSOR NUMBER OF THAT TO BE ASSOCIATED IS
*D*               STORED IN UB:ASP/UB:DB AND THE T:TOTESZ ROUTINE
*D*               IN MM IS CALLED TO INSURE THE SYSTEM HAS SUFFICIENT
*D*               PHYSICAL CORE TO ASSOCIATE THE REQUESTED PROCESSOR.
*D*               IF NOT, CONTROL WILL RETURN TO THE USER WITH CC3 SET.
*D*
         EXU      STORIT,2          **STB,5 ASP/DB,4    NEW SP. SHRD. PROC.
         PUSH     7,1
         LI,7     0                 PHONEY PAGE #
         BAL,0    T:TOTESZ          WOULD ASSOCIATION MAKE HIM TOO BIG
         B        NOPCORE           YES
         PULL     6,2               LEAVE ABNORMAL FLAG IN STACK
*D*
*D*               AT 'ADJSUT' WE ADJUST PB:UC AND PB:REP.
*D*               PB:UC FOR THE PREVIOUSLY ASSOCIATED LIBRARY, OR IF
*D*               NONE WAS ASSOCIATED, FOR THE PREVIOUSLY ASSOCIATED
*D*               DEBUGGER (IF ANY), IS DECREMENTED.
*D*
         LW,3     7                 CURRENT ASP/DB TO R3
ADJUST   MTB,-1   PB:UC,3           (OK TO DECREMENT UC INDEXED BY 0)
*D*
*D*               IF ASSOCIATION OF A LIBRARY CAUSES DISASSOCIATION OF
*D*               ANOTHER LIBRARY, PB:REP FOR THE PREVIOUSLY ASSOCIATED
*D*               LIBRARY IS DECREMENTED.
*D*
         LW,1     *TSTACK
         BEZ      %+2               SAME TYPE NOT CURRENTLY ASSOCIATED
         MTB,-1   PB:REP,3          DECR OLD PROCESSOR
*D*
*D*               PB:UC AND PB:REP FOR THE REQUESTED PROCESSOR IS
*D*               INCREMENTED.  IF IT IS A LIBRARY BEING ASSOCIATED
*D*               CONTROL TRANSFERS TO 'REPORTIT' TO GET THE LIBRARY
*D*               MAPPED INTO THE USER AND RETURN TO THE USER
*D*
         MTB,1    PB:REP,5          INCREASE USERS ASSOCIATED
         MTB,1    PB:UC,5           BUMP ITS COUNT
         BDR,2    CHKIT             BRANCH IF DEBUGGER
         B        REPORTIT          T:REG AND GOBACK
*D*
*D*               IF DELTA IS BEING ASSOCIATED AND THE USER ALSO HAS
*D*               A CORE LIBRARY ASSOCIATED, PB:UC FOR DELTA MUST BE
*D*               DECREMENTED BECAUSE WE HAVE INCORRECTLY INCREMENTED
*D*               IT.  PB:UC FOR THE ASSOCIATED CORE LIBRARY MUST BE
*D*               INCREMENTED BECAUSE WE HAVE INCORRECTLY DECREMENTED
*D*               IT (AT ADJUST).
*D*
CHKIT    EQU      %                 ASSOCIATING A DEBUGGER
         MTB,0    UB:ASP,4          IF THERE IS A LIBRARY,
         BEZ      %+3               THEN
         MTB,-1   PB:UC,5           DEBUGGER NOT IN USE YET
         MTB,1    PB:UC,3           BUT LIBRARY IS
*D*
*D*               IF DELTA HAS NOT BEEN ASSOCIATED WITH THIS USER BEFORE,
*D*               AS INDICATED BY HIS NOT OWNING THE PAGE ABOVE J:EUP,
*D*               THE PPSWAP AND INIT FLAGS IN UH:FLG ARE SET TO
*D*               INDICATE TO THE SWAPPER THAT WE NEED DELTA'S DATA PAGE.
*D*
         LH,15    UH:FLG,4
         LW,7     J:EUP             INIT PAGE PAST USER AREA
         AI,7     1
         LOAD,5   JX:CMAP,7         DOES HE HAVE IT ALREADY
         CI,5     NPMC
         BNE      CHKDEL            YES
         SETR     PPSWP             FLAG FOR SWAPPER
         SETR     INIT              SET FLAG FOR SWAPPER
*D*
*D*               AT 'CHKDEL', IF A BREAK CONTROL ADDRESS FOR DELTA
*D*               WAS SUPPLIED IN WORD 0 OF THE FPT, THIS ADDRESS IS
*D*               STORED IN J:INTENT.
*D*
*D*               IF THE REPORT BREAK FLAG IS SET, INDICATING DELTA
*D*               IS TO BE ENTERED AFTER ASSOCIATION, THE BREAK
*D*               RECEIVED BIT IS SET IN THE USER'S DO-LIST (UH:DL).
*D*
CHKDEL   EQU      %
         LI,7     X'3FFFF'
         AND,6    7                 STORE TVECTOR FROM FPT
         SCS,7    -1
         STS,6    J:INTENT           INTO BREAK CONTROL ADDRESS
         CI,6     X'20000'          IF FLAG SET, ENTER DEBUGGER
         BAZ      NOBRK             AT BREAK ENTRY
         DISABLE
         LH,6     UH:DL,4           SET BRK BIT
         OR,6     BT31TO0+13        =X1000
         STH,6    UH:DL,4
         ENABLE
*D*
*D*               IF DELTA WAS ALREADY ASSOCIATED (DELA SET IN UH:FLG)
*D*               THERE IS NO NEED TO REG THE USER TO ASSOCIATE DELTA
*D*               AND CONTROL RETURNS TO THE USER.  IF NOT THE DELA
*D*               BIT IS SET IN UH:FLG.
*D*
NOBRK    EQU      %
         CI,15    DELA              IF ASSOC IS A NOP
         BANZ     GOBACK            DON'T REG
         SETRST   DELA              ASSOCIATE DELTA
*D*
*D*               AT 'REPORTIT' THE READY TO RUN FLAG IS SET IN UH:FLG
*D*               IN ORDER TO FORCE A SWAP.  THE NEW LIBRARY OR DELTA
*D*               IS ASSOCIATED BY CALLING T:REG WITH THE ASSOCIATE
*D*               PROCESSOR EVENT SPECIFIED.
*D*
REPORTIT EQU      %
         LRSETSST RTR               FORCE A SWAP
         LI,6     E:AP
         BAL,11   T:REG
*D*
*D*               THE ACCESS CODES FOR THE SPECIAL PROCESSOR AREA
*D*               ARE RELOADED VIA THE T:PAC ROUTINE IN MM. FOR
*D*               THE CASE OF CCI ASSOCIATING TEL TO DO SET
*D*               COMMANDS 'TIC' MUST BE RESET FOR T:PAC TO
*D*               CORRECTLY SET THE ACCESS FOR TEL. CONTROL THEN
*D*               RETURNS TO THE USER
*D*
         BAL,R11  CCITEST           CCI GETTING TEL
         B        SETACC            NO
         AND,R15  XFF7F             YES - RESET TIC TO SET ACCESS
         STH,R15  UH:FLG,R4         FOR TEL PROPERLY IN T:PAC
         BAL,R11  T:PAC
         LW,R4    S:CUN
         LH,R15   UH:FLG,R4         AND SET IT AGAIN AFTER SETTING
         OR,R15   X80               ACCESS FOR TEL
         STH,R15  UH:FLG,R4
         B        GOBACK
SETACC   BAL,R11  T:PAC
GOBACK   EQU      %
         PLW,1    TSTACK
         LW,1     1
         BLZ      CC3SET            SET CC3 IF LESS THAN ZERO
         B        CC0RST            RETURN
*
*        T:ASSOCIATE/T:DISASSOCIATE SUBROUTINES
*
*
* STORIT SETS THE NEW LIB/DB FROM R5 INTO UB:ASP/UB:DB
*
STORIT   EQU      %-1
         STB,5    UB:ASP,4          LIB
         STB,5    UB:DB,4           DEBUG
*
* TESTIT LOADS THE OLD LIB/DB INTO R3 FROM UB:ASP/UB:DB
*
TESTIT   EQU      %-1
         LB,3     UB:ASP,4          LIB
         LB,3     UB:DB,4           DEBUG
*
* GETNAME LOADS THE PROCESSOR OF THE REQUESTED PROCESSOR INTO R5
*
GETNAME  EQU      %
         LW,4     S:CUN             CURRENT USER NUMBER
         LH,15    UH:FLG,4          GET USER FLAGS
         CI,15    DIC               DEBUGGER CANT ASSOC OR DISASSOC
         BANZ     CC1SET
         LW,8     *7                GET 1ST WORD OF NAME
         AI,7     1
         LW,9     *7                AND SECOND
         LI,5     PPROCS            MAX NUMBER OF PROCESSORS
         CD,8     P:NAME,5
         BE       *0
         BDR,5    %-2               FIND IT
         B        CC1SET            ERROR, NO NAME
*
* GETTYPE SETS R2=1 IF REQUESTING A LIBRARY
*              R2=2 IF REQUESTING A DEBUGGER
*
GETTYPE  EQU      %
         LW,2     Y3
         AND,2    P:SA,5
         SCS,2    4
         CI,2     3                 IS IT A LIB/DEBUG
         BGE      CC1SET                    NO
         BANZ     *R0               YES
         BAL,R11  CCITEST           IS CCI GETTING TEL
         B        CC1SET            NO
         LI,R2    1                 YES - TEL IS A LIBRARY
         B        *R0
*
*        CCITEST -CHECKS FOR CCI (BATCH-TIC SET) ASSOCIATING TEL
*
CCITEST  CI,R15   TIC               IF TIC SET
         BAZ      *R11
         CI,R15   BAT               FOR A BATCH JOB
         BAZ      *R11
         LD,R8    TXTEL             TRYING TO ASSOCIATE TEL
         CD,R8    P:NAME,R5
         BNE      *R11
         AI,R11   1                 THEN RETURN TO BAL+2
         B        *R11
         PAGE
*F*
*F*      NAME:    T:DISASSOCIATE
*F*
*F*      PURPOSE: TO PROCESS THE DISASSOCIATE PROCESSOR CAL
*F*
*F*      DESCRIPTION:  REFER TO THE T:ASSOCIATE 'F' REPORT FOR A
*F*               DISCUSSION OF PB:UC AND PB:REP.
*F*
*F*               T:DISASSOCIATE VALIDATES THAT THE PROCESSOR MAY BE
*F*               DISASSOCIATED.  PB:UC AND PB:REP ARE ADJUSTED AS
*F*               EXPLAINED IN THE T:ASSOCIATE 'F' REPORT.
*F*
*D*      NAME:    T:DISASSOCIATE
*D*
*D*      DATA:    FPT, WORD 0   = GEN,8,24  5,0
*D*               FPT, WORD 1-2 = TEXTC PROCESSOR NAME
*D*
*D*      INPUT:   R6 = 1ST WORD OF THE FPT
*D*               R7 = WA(FPT+1)
*D*
*D*      INTERFACE: T:RVPI, T:PAC
*D*
*D*      DESCRIPTION:  THE P:NAME TABLE IS SEARCHED FOR THE PROCESSOR
*D*               SPECIFIED IN THE FPT.  IF NOT FOUND, CONTROL RETURNS
*D*               TO THE USER WITH CC1 SET.
*D*
T:DISASSOCIATE EQU   %
         BAL,0    GETNAME           R5 = PROCESSOR NUMBER
*D*
*D*               IF THE PROCESSOR SPECIFIED IS NOT A CORE LIBRARY OR
*D*               A DEBUGGER, CONTROL RETURNS TO THE USER WITH CC1 SET.
*D*
         BAL,0    GETTYPE           R2 = 1 IF LIB.   R2 = 2 IF DEBUGGER
*D*
*D*               IF A PROCESSOR OF THE TYPE SPECIFIED IS NOT ASSOCIATED
*D*               CONTROL RETURNS TO THE USER WITH CC2 SET.
*D*
*D*               IF THE PROCESSOR SPECIFIED IS NOT ASSOCIATED WITH THE
*D*               USER, CONTROL RETURNS WITH CC1 SET.
*D*
         EXU      TESTIT,2          IS ONE ASSOCIATED
         BEZ      CC2SET            NO
         CW,3     5                 IS IT THE ONE REQUESTED
         BNE      CC1SET            NO,SET CC1
*D*
*D*               IF DELTA IS BEING DISASSOCIATED, DELA IS RESET IN
*D*               UH:FLG, DELTA'S BREAK CONTROL ADDRESS IS RESET, AND
*D*               DELTA'S DATA PAGE IS RELEASED.
*D*
         LI,5     0
         CI,2     2                 WAS IT DEBUGGER
         BNE      CHKDEL2           NO
         RSETSST  DELA              RESET DELA
         STW,5    J:INTENT          ZAP BREAK CONTROL ADDR
         PUSH     4,2
         LW,7     J:EUP
         AI,7     1
         BAL,11   T:RVPI            RELEASE DELTAS DATA PAGE
         NOP
         PULL     4,2
*D*
*D*               THEN, IF A LIBRARY IS NOT CURRENTLY ASSOCIATED WITH
*D*               THE USER, BOTH PB:UC AND PB:REP FOR DELTA ARE
*D*               DECREMENTED.  THE ACCESS CODES FOR THE SPECIAL
*D*               PROCESSOR AREA ARE RELOADED AND CONTROL RETURNS
*D*               TO THE USER WITH ALL CC RESET.
*D*
*D*               HOWEVER, IF A LIBRARY IS ASSOCIATED WITH THE USER,
*D*               ONLY PB:REP FOR DELTA IS DECREMENTED BECAUSE PB:UC
*D*               DOES NOT INCLUDE THIS USER WHEN THE USER PROGRAM IS
*D*               IN EXECUTION.
*D*
         LB,1     UB:ASP,4          IS LIBRARY ALSO ASSOCIATED
         BEZ      CHKDEL2+1         NO-DECREMENT UC AND REP
         LI,1     0                 LIBRARY PROCEDURE IS IN CMAP
         B        CHKDEL2+2         DONT DECREMENT USE COUNT
*D*
*D*               IF A LIBRARY IS BEING DISASSOCIATED, PB:UC AND
*D*               PB:REP FOR THE LIBRARY ARE DECREMENTED.  IF DELTA
*D*               IS ASSOCIATED WITH THE USER, PB:UC FOR DELTA IS
*D*               INCREMENTED AND CONTROL TRANSFERS TO THE 'REPORTIT'
*D*               LOGIC IN THE T:ASSOCIATE LOGIC TO MAP DELTA INTO
*D*               THE USER'S SPECIAL PROCESSOR AREA.
*D*
*D*               IF DELTA IS NOT ASSOCIATED, THE ACCESS CODES FOR
*D*               THE SPECIAL PROCESSOR AREA ARE RELOADED AND CONTROL
*D*               RETURNS TO THE USER WITH ALL CC RESET.
*D*
CHKDEL2  EQU      %                 DISASSOCIATING LIBRARY
         LB,1     UB:DB,4           GET DEBUGGER-IF ANY
         MTB,-1   PB:UC,3           DECR COUNT
         MTB,-1   PB:REP,3          DECREASE USERS ASSOCIATED
         EXU      STORIT,2          ZAP THE LIB/DEB
         LW,1     1                 IS DELTA NOW ASSOCIATED
         BEZ      CUD3              NO
         MTB,1    PB:UC,1
         LI,1     0
         PSW,1    TSTACK            SIGNAL NORMAL EXIT
         B        REPORTIT          GET DELTA BACK IN CMAP
CUD3     EQU      %
         BAL,11   T:PAC             SET ACCESS
         B        CC0RST
         PAGE
*F*
*F*      NAME:    T:SAVEGET
*F*
*F*      PURPOSE: TO PROCESS THE SAVE/GET CALS.
*F*
*F*      DESCRIPTION:  THE SAVE AND GET CALS WERE IMPLEMENTED TO
*F*               PROVIDE USER INFORMATION TO TEL WHEN PROCESSING
*F*               THE !SAVE AND !GET CONTROL COMMANDS.
*F*
*F*               T:SAVEGET TRANSFERS CONTROL TO T:SAVE1 IF PROCESSING
*F*               A SAVE CAL.
*F*
*F*               IF PROCESSING A GET CAL, AND TIC BIT IS NOT SET IN
*F*               UH:FLG INDICATING THE CAL WAS ISSUED BY A COMMAND
*F*               PROCESSOR, THE USER IS RE-ENTERED WITH CC1 SET.
*F*               OTHERWISE CONTROL TRANSFERS TO T:GET.
*F*
*F*      REFERENCE: T:SAVE1 AND T:GET 'F' REPORTS.
*F*
T:SAVEGET EQU     %
         LW,4     S:CUN             GET THIS USERS FLAGS
         LH,2     UH:FLG,4
*
         AI,8     -2                ADJUST FPT CODE
         BLZ      CC1SET
         BEZ      T:SAVE1
*
         CI,8     1
         BNE      CC1SET
*                                   ONLY TEL HAS ACCESS
         CI,2     TIC               TO THE GET CAL
         BAZ      CC1SET            BRANCH IF NOT TEL
         B        T:GET             OK IF COMMAND PROCESSOR
         PAGE
*F*
*F*      NAME:    T:GET
*F*
*F*      PURPOSE: TO PROCESS THE GET CAL
*F*
*F*      DESCRIPTION:  THE GET CAL IS ISSUED BY TEL AFTER RESTORING A
*F*               USER FOLLOWING A !GET CONTROL COMMAND.
*F*
*F*               T:GET VALIDATES THAT IT IS LEGAL TO RESTORE THE
*F*               PROCESSORS SPECIFIED IN J:CPROCS.  IF SO, THE
*F*               VALUES IN J:CPROCS AND J:CFLGS ARE TRANSFERED TO
*F*               THE APPROPRIATE USER TABLES.
*F*
*D*      NAME:    T:GET
*D*
*D*      REGISTERS: R6-R11 SAVED
*D*                 R0-R5 AND R12-R15 VULNERABLE
*D*
*D*      DESCRIPTION:  IF A STANDARD SHARED PROCESSOR IS ASSOCIATED
*D*               A CHECK IS MADE TO DETERMINE IF THE PROCEDURE AREA
*D*               FOR THAT PROCESSOR # IS THE SAME AS THE PROCEDURE
*D*               AREA ESTABLISHED IN JIT BY TEL WHEN RESTORING THE
*D*               SAVE FILE.  IF NOT CONTROL RETURNS TO TEL WITH
*D*               CC1 SET.
*D*
T:GET    EQU      %
*                                   REPLACE IN USER TABLES
         PUSH     6,6
         LB,1     J:CPROCS          L/APR #
         BEZ      GET02             BEZ; NO APR
         LW,0     P:SA,1            IF SJAC PROCESSOR
         BLZ      GETERR            DONT ALLOW GET
         LB,0     PB:PVA,1          L/PB:PVA (PP PA) FOR APR
         BEZ      GETERR            BEZ; APR DOESN'T EXIST
         CW,0     J:PLL             C/PVA W/PP LOWER LIMIT IN JIT
         BNE      GETERR            BNE; NOT SAME APR
         LB,0     PB:HVA,1          L/PB:HVA (HIGH PP PA + 1) FOR APR/APO
         AI,0     -1                -1; J:PUL = PB:HVA - 1
         CW,0     J:PUL             C/HVA-1 W/PP UPPER LIMIT IN JIT
         BNE      GETERR            BNE; NOT SAME APR/APO
*D*
*D*               IF TEL HAS RESTORED DCBS FROM THE SAVE FILE THE DCB
*D*               CHECKER IN THE STEP OVERLAY IS CALLED TO VALIDATE
*D*               THE RESTORED DCBS.  IF ANY ERRORS ARE DETECTED
*D*               CONTROL RETURNS TO TEL WITH CC1 SET.
*D*
GET02    MTW,0    J:DCBLINK         ADDR OF DCB TAB
         BEZ      GET06             B IF NO DCBS
         PUSH     4,R2              SAVE R2 - R5
         LI,14    SBUF2VPA          GET SPECIAL BUFFER 2 TO
         BAL,2    T:GBUF            USE FOR DCB CHECK
         LW,2     J:DCBLINK         DCB TABLE ADDRESS
         LB,1     JB:PCDCB          # OF PAGES OF DCBS
         SLS,1    9                 # OF WORDS OF DCBS
         LW,R0    J:DCBLL           ADD OF 1ST PAGE OF DCBS
         SLS,R0   9                 ADD OF 1ST WORD OF DCBS
         LI,R4    SBUF2VPA          ADD OF BUFFER FOR DCB CHECKER
         LI,5     1                 SPECIAL INIT FOR TEL GET
         PUSH     0
         PUSH     2                 REGS PULLED BY STEPOVR
         OVERLAY  STEPOVRSEG,DCBCHK#
         LI,14    SBUF2VPA          RETURN BUFFER
         LI,5     0
         BAL,2    T:RBUF
         PULL     4,R2              RESTORE R2 - R5
         AI,6     0                 CHECK CC
         BNEZ     GETERR            ERR IN DCBS
*D*
*D*               THE DELA (DELTA ASSOCIATED) AND DIC (DELTA IN
*D*               CONTROL) BITS THAT WERE SET AT THE TIME THE
*D*               ENVIRONMENT WAS SAVED ARE NOW RESTORED IN UH:FLG.
*D*
GET06    EQU      %
         LW,0     J:CFLGS
         LH,2     UH:FLG,4
         LI,1     DIC|DELA
         STS,0    2
         STH,2    UH:FLG,4
*D*
*D*               IF A CORE LIBRARY OR DEBUGGER (DELTA) IS ASSOCIATED
*D*               A CHECK IS MADE TO DETERMINE IF THE FLAGS IN P:SA
*D*               FOR THAT PROCESSOR # INDICATE LIBRARY OR DEBUGGER.
*D*               IF NOT CONTROL RETURNS TO TEL WITH CC1 SET.
*D*
         LW,0     J:CPROCS
         LI,1     -2
GET07    EQU      %
         STB,0    6                 PROC #
         LB,6     6                    TO R6
         BEZ      GET07A            NO PROC, GO TO NEXT
         CB,0     PROCLIMT          IS NUMBER > MAX PROC #
         BG       GETERR            YES
         LW,2     P:SA,6            GET FLAGS FOR THIS PROC
         LC       2                 CHECK FOR
         EXU      FLAGTST,1            LEGAL FLAGS
*D*
*D*               OR IF THE PROCEDURE AREA FOR THA PROCESSOR # IS
*D*               BELOW THE SPECIAL PROCESSOR AREA CONTROL RETURNS
*D*               TO TEL WITH CC1 SET.
*D*
         LB,2     PB:PVA,6          GET FIRST VP #
         BEZ      GETERR            PROC DOESN'T EXIST
         CI,2     JSPVP             IS 1ST PAGE IN SP PR AREA
         BL       GETERR            NO, BIASED TOO LOW
*D*
*D*               OTHERWISE THE LIBRARY OR DEBUGGER PROCESSOR # IS
*D*               STORED IN UB:ASP/UB:DB, AND PB:REP IS INCREMENTED
*D*               FOR THAT PROCESSOR #.
*D*
         EXU      UTBLSET,1         STORE # IN PROPER USER TABLE
         MTB,1    PB:REP,6          INCR USERS ASSOCIATED
GET07A   EQU      %
         SLS,0    -8                SHIFT TO ASP
         BIR,1    GET07
*
*D*
*D*               IF A SHARED PROCESSOR OVERLAY IS ASSOCIATED, THE
*D*               PROCESSOR # FOR THAT OVERLAY MUST BE WITHIN THE P:NAAME
*D*               TABLE.  IF NOT CONTROL RETURNS TO TEL WITH CC1 SET.
*D*
         CB,R0    OLAYLIMT          C/APO # W/MAX LEGAL + 1
         BG       GETERR
*D*
*D*               IF A PROCESSOR OVERLAY (UB:APO) IS ASSOCIATED, BUT
*D*               A SHARED PROCESSOR (UB:APR) IS NOT, CONTROL RETURNS
*D*               TO TEL WITH CC1 SET.
*D*
         SLD,0    -8                R0=APR,  R1(BYTE0)=APO
         LB,2     1                 R2=APO
         BEZ      GET09             NO APO, STORE ZERO
         AI,0     0                 APO IMPLIES APR,
         BEZ      GETERR               ELSE ERROR
*D*
*D*               THE PROCESSOR OVERLAY MUST BE IN THE PB:LNK (OVERLAY
*D*               LINK) CHAIN FOR THE PROCESSOR OR CONTROL RETURNS TO
*D*               TEL WITH CC1 SET.
*D*
         LW,6     0                 R6=APR
GET08    LB,6     PB:LNK,6          GET NEXT OLAY #
         BEZ      GETERR            END OF OLAY CHAIN & NOT FND
         CB,6     1                 IS IT THIS OLAY
         BNE      GET08             NO, CONTINUE DOWN CHAIN
*D*
*D*               OTHERWISE, THE PROCESSOR OVERLAY # IS STORED IN
*D*               UB:APO AND THE ACCESS CODES FOR THE PAGES IN THE
*D*               OVERLAY AREA ARE SET TO 01.
*D*
GET09    STB,2    UB:APO,4          STORE IN USER TABLE
         CI,2     0                 IF THE USER HAS NO PROC,
*                                   DON'T SET ACCESS
         BE       GET10
*D*
         BAL,R1   GETSNAC           SET 01 ACCESS FOR OLAY
*D*
*D*               THE ACCESS CODES FOR PAGES IN THE SHARED PROCESSOR
*D*               ROOT ARE SET TO 01.
*D*
GET10    EQU      %
         CB,0     PROCLIMT
         BG       GETERR
*
         STB,0    2                 PROC #
         LB,2     2                 IF THE USER HAS NO PROC,
*                                   DON'T SET ACCESS
         BE       GET20
*
         LI,R1    GET20             SIM. BAL
GETSNAC  EQU      %
         PUSH     0
         PUSH     4
         LI,4     1
         LB,6     PB:PSZ,2
         LB,7     PB:PVA,2
         BAL,11   T:SNAC            SET 01 ACCESS/OR THIS PROC
         PULL     4
         PULL     0
         B        0,1               RETURN ON R1
*
*  THIS IS AN EXU LIST
         BCR,2    GETERR            DEBUG NOT SET
         BCR,5    GETERR            PUB. LIB OR SP SHR PROC NOT SET
FLAGTST  EQU      %
         STB,0    UB:DB,4           STORE DEBUGGER #
         STB,0    UB:ASP,4          STORE ASP #
UTBLSET  EQU      %
*D*
*D*               THE SHARED PROCESSOR # IS STORED IN UB:APR AND
*D*               PB:RREP FOR THE PROCESSOR IS INCREMENTED.
*D*
*D*               CONTROL THEN RETURNS TO TEL WITH CC1 RESET.
*D*
GET20    EQU      %
         STB,0    UB:APR,4
         LW,6     0
         AND,6    M8                INCREASE NUMBER OF USERS ASSOCIATED
         MTB,1    PB:REP,6
         PULL     6,6
         B        CC1RST
*
GETERR   EQU      %
         LI,6     0                 ZAP DCBLINK TO PREVENT
         STW,6    J:DCBLINK         S/C 2E IN DCB RUNDOWN
         PULL     6,6
         B        CC1SET
*
         PAGE
*F*
*F*      NAME:    T:SAVE1
*F*
*F*      PURPOSE: TO PROCESS THE SAVE CAL
*F*
*F*      DESCRIPTION:  T:SAVE1 STORES THE VALUES FROM UB:APR, UB:APO,
*F*               UB:ASP AND UB:DB IN J:CPROCS IN THE USER'S JIT.
*F*
*F*               UH:FLG IS STORED IN J:CFLGS (BITS 16-32) IN THE
*F*               USER'S JIT.
*F*
*
T:SAVE1  EQU      %                 SAVE USERS PROC#S IN JIT
         LI,3     1
         LB,0     UB:APR,4
         STB,0    J:CPROCS
         LB,0     UB:APO,4
         STB,0    J:CPROCS,3
         LI,3     2
         LB,0     UB:ASP,4
         STB,0    J:CPROCS,3
         LI,3     3
         LB,0     UB:DB,4
         STB,0    J:CPROCS,3
         LI,3     X'FFFF'
         STS,2    J:CFLGS
         B        CC1RST
         PAGE
*F*
*F*      NAME:    T:GHOST
*F*
*F*      PURPOSE: TO OUTPUT AN ERROR MESSAGE ON THE OPERATOR'S
*F*               CONSOLE WHEN A GHOST JOB HAS ABORTED.
*F*
*F*      DESCRIPTION: THE 'GJOB NAME,ACCT ERR' MESSAGE IS BUILT IN
*F*               J:CCBUF IN THE USER'S JIT.  MSROCTY IN WRTD IS
*F*               CALLED TO OUTPUT THE MESSAGE.
*F*
*D*      NAME:    T:GHOST
*D*
*D*      CALL:    OVERLAY  MISOVSEG,T:GHOST#
*D*                ENTERED FROM THE STEP OVERLAY
*D*
*D*      REGISTERS: ALL REGISTERS ARE SAVED
*D*
T:GHOST  EQU      %
         PUSH     16,0
         LI,1     5
         LI,2     BA(GJOBMS)        MOVE 'GJOB' TO OUTPUT BUF
         LI,3     BA(J:CCBUF)+1
         BAL,0    MOVER
*
         LI,1     7                 MAX. 7 CHARS.
         LI,2     JB:PNR            GET GJOB INDEX
         LB,2     0,2
         SLS,2    3                 TO BYTES
         AI,2     BA(S:GJOBTBL)+1   SKIP COUNT
         BAL,11   MVACT10
*
         LI,2     BA(ERRMSG)
         LI,1     4                 MOVE 'ERR' TO BUF
         BAL,0    MOVER
*
         AI,3     -BA(J:CCBUF)-1
         STB,3    J:CCBUF           STORE BYTE COUNT IN BUFFER
*
         LI,8     2                 TYPE CODE
         LW,R7    TSTACK
         AI,R7    1                 ADDRESS OF FPT
         LCI      2
         LM,12    PLIST
         PSM,12   TSTACK            MOVE FPT TO STACK
*
         BAL,11   MSROCTY           'GJOB ON' TO OC
*
         PULL     2,12              REMOVE FPT
*
*
*
         PULL     16,0
         B        *11
GJOBMS   TEXT     'GJOB'
BLNKS    TEXT     '    '
ERRMSG   TEXT     ' ERR'
PLIST    GEN,1,31  1,0
         DATA     J:CCBUF
         PAGE
MVNAMDAT EQU      %
         PUSH     11
         BAL,11   MVNAMACT
         LI,2     BA(BLNKS)
         LI,1     4
         BAL,0    MOVER
         BAL,11   MVDATIME
         PULL     11
         B        T:SELFDESTRUCT
         PAGE
*    MOVE 'NAME, ACCOUNT #'
*    INPUT R3 STARTING BYTE ADDRESS OF DESTINATION BUFFER
MVNAMACT EQU      %
         LI,1     12
         LI,2     BA(J:UNAME)
MVACT10  BAL,0    MOVER             TO SPECIFIED BUFFER
*
         BAL,0    DELETBLNKS        DELETE TRAINING BLANKS
*
         LI,0     ','               INSERT A COMMA
         STB,0    0,3
         AI,3     1
*
         LI,1     8
         LI,2     BA(J:ACCN)        MOVE USERS ACCOUNT #
         BAL,0    MOVER             TO BUFFER
*
         BAL,0    DELETBLNKS        DELETE TRAILING BLANKS
*
OVRTN    EQU      %
         CI,11    JOVVPA
         BG       *11               IF IN THIS OVERLAY, RETURN
         B        T:SELFDESTRUCT
*
*
DELETBLNKS EQU    %                 DELETE-TRAILING-BLANKS ROUTINE
         AI,3     -1
         LI,4     ' '
DBK10    EQU      %
         CB,4     0,3               LOOK FOR NON-BLANK CHAR
         BNE      DBK20             BRANCH IF FOUND
*
         BDR,3    DBK10             LOOP
         SCREECH  X'1C'             RECOVER
*
DBK20    EQU      %
         AI,3     1
         B        *0
*
*
MVDATIME EQU      %
         LI,1     2
         LI,2     BA(DATE)          MOVE DAY TO BUFFER
         BAL,0    MOVER
*
         LI,4     '/'
         STB,4    0,3
         AI,3     1
*
         LI,1     2
         BAL,0    MOVER             TO BUFFER
*
         LI,4     '/'
         STB,4    0,3
         AI,3     1
         LI,1     2
         LI,2     BA(DATE)+6
         BAL,0    MOVER
*
         LI,1     4
         LI,2     BA(BLNKS)         FOUR BLANKS
         BAL,0    MOVER
*
         LI,1     2
         LI,2     BA(TIME)          HOURS
         BAL,0    MOVER
*
         LI,4     ':'
         STB,4    0,3               AND
         AI,3     1
*
         BAL,0    MOVER             MINUTES TO BUFFER
*
         B        OVRTN
*
*
*        R0       LINK
*        R1       BYTE COUNT FOR MOVE
*        R2       BYTE ADR OF SOURCE BUFFER
*        R3       BYTE ADR OF DESTINATION BUFFER
MOVER    EQU      %
         STB,1    3                 COUNT TO R3
         MBS,2    0                 MOVE IT
         B        *0
         PAGE
*        THIS ROUTINE SETS THE CONDITION CODES IN THE USERS PSD
*        IN HIS TEMP STACK AND RETURNS TO CAL+1 EVENTUALLY
*
CC0RST   LI,0     0
         B        SETCC
CC1SET   LW,0     Y8
         B        SETCC
CC2SET   LW,0     Y4
         B        SETCC
CC3SET   LW,0     Y2
SETCC    EQU      %
         LW,1     YF
*
         LI,4     -17               COMPUTE DOUBLEWORD ADR OF PSD
         AW,4     TSTACK            IN USERS TEMP STACK
         LD,2     *4
         STS,0    2                 STORE CONDITION CODES
         STD,2    *4
         DESTRUCT TRAPEXIT
*
NOPCORE  PULL     7,1
         LW,5     3                 RESET CURRENT ASP/DB BECAUSE NEW ONE
         EXU      STORIT,2           WASNT ASSOCIATED
CC4SET   LW,0     Y1
         B        SETCC
CC1RST   EQU      CC0RST
         TITLE    'MSRKEYIN'
*F*
*F*      NAME:    MSRKEY
*F*
*F*      PURPOSE: TO PROCESS THE M:KEYIN CAL.
*F*
*D*      NAME:    MSRKEY
*D*
*D*      CALL:    OVERLAY MISOV,MSRKEY#
*D*                 (ENTERED FROM CALPROC)
*D*
*D*      INPUT:   R11 = RETURN  (TRAPEXIT)
*D*               R7 = WA(FPT + 1)
*D*
*D*      DATA:    FORMAT OF THE FPT
*D*
*D*               WORD 0 - 04000000
*D*               WORD 1 - P1->P4,00000,F1,0
*D*               P1     - MESSAGE ADDRESS (TEXTC FORMAT)
*D*               P2     - REPLY ADDRESS
*D*               P3     - REPLY SIZE (IN BYTES)
*D*               P4     - ECB ADDRESS
*D*
*D*               F1 - IF SET, AND THE USER IS ON-LINE, THE MESSAGE
*D*                    IS TO GO TO THE OC DEVICE RATHER THAN THE
*D*                    DEFAULT USER'S CONSOLE.
*D*
MSRKEY   EQU      %
         LI,6     6
         BAL,1    PUSHALL
         LI,9     MSROCTY+X'80000'  OC ADDR+NEGATIVE REG
         LW,6     0,7               M:OC REQUESTED
         CI,6     X'10'             OCONLY FLAG
         BANZ     %+2
         LI,9     MSRTYPR           NOT OC ONLY
         BAL,11   *9                GO TO APPROPRIATE ROUTINE
         LI,R6    M:UC              L/ADR OF M:UC; ASSUME ON-LINE
         LH,D4    J:JIT             L/LH OF WD 0 OF JIT
         BGEZ     %+2               NOT ONLINE, USE M:OC
         BDR,9    MSRKY0
         LCI      8                 L/CC'S OF 8 FOR LM/PSM
         LM,SR4   MOC               L/SKELETON OF DCB
         PSM,SR4  TSTACK            PUSH INTO TSTACK
         LW,R6    TSTACK            L/TOP OF STACK POINTER
         AI,R6    -7                -7; G/ADR OF DCB
MSRKY0   RES      0
         LI,R0    K40               SET BTD TO A ONE
         BAL,D4   SETBTDQ1
*
         BAL,R2   CHKBIT1
         B        %+1
         BAL,R2   CHKBIT
         LI,D2    K1FFFF
         STS,D1   QBUF,R6
         BAL,R2   CHKBIT
         B        %+2               REPLY SIZE
         LI,D1    60                USE DEFAULT FOR LIMIT
         LW,D4    D1
         BAL,R0   SAVBLK
         BAL,R2   CHKBIT
         LW,R7    D1                ECB ADDRESS
         STW,D4   SR3               SAVE D4
         LI,D4    0                 NEED ONLY CHECK 1 PAGE
         BAL,R0   CKLIMIT
         BCS,3    ABORT             ACCESS IN CC
         LW,D4    SR3                 RESTORE D4
         LW,SR3   D1
         LI,R7    X'1FFFF'
         AND,R7   QBUF,R6
         BAL,R0   CKLIMIT
         BCS,3    ABORT
*
*
*
         LI,R2    BAFCN
         MTB,1    *R6,R2            INCREMENT FUNCTION COUNT
         LW,R3    Y008
         STS,R2   0,R6
*                                   SET UP REGISTERS FOR QUEUE
*                                   OPCODE
         LW,SR1   R6
         LI,R5    BA(JB:PROMPT)
         LB,R7    0,R5              SAVE CURRENT PROMPT CHAR
         STB,R3   0,R5              ZERO SO READ WON'T PROMPT
         BAL,SR4  QUEUE             DO IO
         STB,R7   0,R5              RESTORE OLD PROMPT
         BAL,SR4  IOSPIN
         LW,R0    ARS,R6            L/ARS (ACT REC SIZE) FROM DCB
         SLS,R0   -17               RJ/ARS
         LW,R6    QBUF,R6           L/USER'S BUFFER ADR
         STB,R0   *R6               S/ARS IN BYTE 0 OF USER'S BUFFER
         LW,R1    Y8                L/BIT 0 MASK
         STS,R0   *SR3              RESET BIT 0 IN USER'S ECB
*                                   EXIT
         DESTRUCT MSRWRTX
MOC      DATA     X'00200003'       DCB ASSIGNED TO OC
         GEN,8,7,2,7,8   10,3,1,1,OCDCT
         DATA     X'0A000000'       10 RETRIES
         DATA     0,0,0,0,0
*
ABORT    LI,14    X'4A'
         B        T:ABORTM
*E*  ERROR:        4A-00
*E*  DESCRIPTION:  REPLY BUFFER ON M:KEYIN NOT IN PROTECTION
*E*                TYPE 00.
ARS      EQU      4
BAFCN    EQU      X'1C'
K1FFFF   EQU      X'1FFFF'
K40      EQU      X'40'
QBUF     EQU      7
         BOUND    8
TXTEL    TEXTC    'TEL'
         DATA     '    '
         SPACE    5
UCALSIZ  EQU      %-UCAL
         END      UCAL

