TITLE  'ICATS TERMINAL INTERRUPT HANDLER'                      DOT00010
*********************************************************************** DOT00020
*                                                                     * DOT00030
*  MODULE NAME =  ICATS TERMINAL INTERRUPT HANDLER                    * DOT00040
*                                                                     * DOT00050
*  FUNCTION =  PROCESS AN INTERRUPT FROM A DIAL-ABLE TERMINAL.        * DOT00060
*                                                                     * DOT00070
*  ENTRY POINTS =  DOTERM                                             * DOT00080
*                                                                     * DOT00090
*  LINKAGE =  BALR R14,R15 FROM ICATS MAINLINE.                       * DOT00100
*                                                                     * DOT00110
*  REGISTER CONTENTS UPON ENTRY =                                     * DOT00120
*      R2  = POINTS TO THE ICATS COMMON DATA AREA AS ALWAYS.          * DOT00130
*      R14 = RETURN ADDRESS BACK TO ICATS MAINLINE.                   * DOT00140
*      R15 = ENTRY POINT TO THIS MODULE                               * DOT00150
*                                                                     * DOT00160
*  REGISTER USAGE =                                                   * DOT00170
*      R0  = USED TO PASS PARAMETERS TO SOME SUBROUTINES.             * DOT00180
*      R1  = USED TO PASS PARAMETERS TO SUBROUTINES.                  * DOT00190
*      R2  = USED TO ADDRESS THE ICATS COMMON DATA AREA.              * DOT00200
*      R3  = FREE                                                     * DOT00210
*      R4  = USED TO ADDRESS THE UTS CONTROL BLOCKS.                  * DOT00220
*      R5  = USED TO ADDRESS THE USER CONTROL BLOCKS.                 * DOT00230
*      R6  = USED TO ADDRESS THE DISK CONTROL BLOCKS.                 * DOT00240
*      R7  = MOSTLY FREE, BUT USED TO ADDRESS THE SMSG BUFFER QUEUE.  * DOT00250
*   R8-R10 = FREE                                                     * DOT00260
*      R11 = FIRST BASE REGISTER                                      * DOT00270
*      R12 - R13 = FREE                                               * DOT00280
*      R14 = MY RETURN ADDRESS WHEN I CALL SOMEBODY                   * DOT00290
*      R15 = SUBROUTINE ADDRESS                                       * DOT00300
*                                                                     * DOT00310
*  MODULE LOGIC =                                                     * DOT00320
*     COME HERE FROM THE DISPATCHER ROUTINE WITH INTERRUPTS STILL     * DOT00330
*     DISABLED WHEN WE'VE RECEIVED AN INTERRUPT FROM ONE OF THE       * DOT00340
*     TERMINALS WE'RE SERVICING.                                      * DOT00350
*     1)  LOOP THROUGH THE TERMINAL CONTROL BLOCK CHAIN AND FIND      * DOT00360
*         THE ONE THAT INTERRUPTED US (IF ANY).                       * DOT00370
*         A)  IF NO TERMINAL NEEDS SERVICING, THEN                    * DOT00380
*             1)  TURN OFF THE A-TERMINAL-NEEDS-SERVICING FLAG.       * DOT00390
*             2)  TURN INTERRUPTS BACK ON.                            * DOT00400
*             3)  RETURN TO THE DISPATCHER.                           * DOT00410
*         B)  IF ONE IS FOUND, THEN TURN INTERRUPTS BACK ON AND       * DOT00420
*             SEE WHICH STATE THIS TERMINAL IS IN.  A TERMINAL        * DOT00430
*             SHOULD BE IN ANY ONE OF THREE STATES.                   * DOT00440
*             1)  IF HE'S PLUGGED INTO A UTS ALREADY, THEN            * DOT00450
*                 A)  DO A READ MODIFIED.  SAVE THE DATA IN HIS       * DOT00460
*                     TERMINAL BLOCK FOR FUTURE USE (THE UTS WILL     * DOT00470
*                     PROBABLY DO A READ MODIFIED).                   * DOT00480
*                 B)  SEE IF ANY OF THE MODIFIED FIELDS IS HIS        * DOT00490
*                     SESSION TERMINATE STRING (USUALLY "$$$$").      * DOT00500
*                     IF IT IS, THEN HE WANTS OUT FROM THE UTS        * DOT00510
*                     AND BACK TO THE ORIGINAL MENU.  TURN OFF        * DOT00520
*                     PLUGGED-IN BIT AND GO TO STEP 1) B) 2).         * DOT00530
*                 C)  IF HE DIDN'T WANT OUT, THEN GO AHEAD AND        * DOT00540
*                     PASS THIS INTERRUPT ON TO THE UTS.  DON'T       * DOT00550
*                     WAIT AROUND FOR THE UTS TO RESPOND, JUST        * DOT00560
*                     RETURN TO THE DISPATCHER.  WHEN THE UTS         * DOT00570
*                     GETS AROUND TO DOING A READ MODIFIED OR         * DOT00580
*                     WHATEVER, I'LL DO THAT I/O THEN.                * DOT00590
*                     IF YOU GET AN ERROR PASSING THE INTERRUPT       * DOT00600
*                     ON TO THE UTS, ASSUME THE UTS WENT DOWN         * DOT00610
*                     AND BOUNCE THIS GUY BACK TO THE MENU WITH       * DOT00620
*                     AN APPROPRIATE MESSAGE.                         * DOT00630
*             2)  IF HE'S NOT ALREADY PLUGGED INTO A UTS, THEN        * DOT00640
*                 SEE IF HE'S SEEN A MENU YET.  IF NOT,               * DOT00650
*                 A)  DO A WRITE TO HIS SCREEN AND GIVE HIM A MENU.   * DOT00660
*                 B)  RETURN TO THE DISPATCHER.                       * DOT00670
*             3)  IF HE'S NOT ALREADY PLUGGED INTO A UTS AND HAS      * DOT00680
*                 ALREADY GOTTEN A MENU, THEN SEE WHAT HE WANTS       * DOT00690
*                 TO DO.  DO A READ MODIFIED.                         * DOT00700
*                 A)  IF HE HIT PA1, THEN HE WANTS OUT COMPLETELY.    * DOT00710
*                     DO A CP DETACH XXX (WHATEVER ADDRESS HE'S AT)   * DOT00720
*                     AND REDEFINE THAT TERMINAL (CP DEFINE GRAF XXX).* DOT00730
*                 B)  CHECK HIS SESSION TERMINATE STRING.  STORE      * DOT00740
*                     WHATEVER VALUE IS IN THAT FIELD.                * DOT00750
*                 C)  SEE IF HE SELECTED A VALID UTS.  IF SO,         * DOT00760
*                     GIVE THE UTS AN ASYNCHRONUOUS, DEVICE END       * DOT00770
*                     INTERRUPT FROM THIS TERMINAL.  IT'LL APPEAR     * DOT00780
*                     TO THE UTS THAT THIS TERMINAL WAS JUST          * DOT00790
*                     POWERED ON.                                     * DOT00800
*                 D)  IF THE UTS HE'S SELECTED IS OFFLINE, THEN       * DOT00810
*                     CALL THE ATTACH MODULE TO TRY TO BRING IT       * DOT00820
*                     ONLINE.  THEN GO BACK TO 1) B) 3) C).           * DOT00830
*                 E)  RETURN TO THE DISPATCHER.                       * DOT00840
*                                                                     * DOT00850
*  EXTERNAL REFERENCES = NONE                                         * DOT00860
*                                                                     * DOT00870
* CONTROL BLOCKS =  ICDATA    ICATS COMMON DATA AREA                  * DOT00880
*                   UTSCB     UTS MACHINE CONTROL BLOCK               * DOT00890
*                   USERCB    USER FOR THIS UTS CONTROL BLOCK         * DOT00900
*                   DISKCB    DISK FOR THIS USER CONTROL BLOCK        * DOT00910
*                   TERMCB    DIAL-ABLE TERMINALS CONTROL BLOCK       * DOT00920
*                                                                     * DOT00930
*                                                                     * DOT00940
*  NON-STANDARD MACROS (FOUND IN ICATS MACLIB)                        * DOT00950
*            ICDATA = ICATS COMMON DATA AREA DSECT.                   * DOT00960
*            ETTE   = ENTER TRACE TABLE ENTRY SUBROUTINE              * DOT00970
*                                                                     * DOT00980
*  CHANGE ACTIVITY                                                    * DOT00990
*    DATE        NAME       REASON FOR CHANGE                         * DOT01000
*  05/31/83  RICK JASPER    INITIAL PROGRAM CREATION                  * DOT01010
*  01/30/84  RICK JASPER    GOT A UNIT CHECK WRITING TO A 3278-5      * DOT01020
*                           TERMINAL.  PROBLEM WAS I WAS COMPUTING    * DOT01030
*                           THE SET BUFFER ADDRESSES BASED ON A 132   * DOT01040
*                           CHARACTER LINE WIDTH, BUT WRITING THE     * DOT01050
*                           SCREEN IN STANDARD MODE (80-CHARACTER     * DOT01060
*                           LINE WIDTH).  THAT MEANS ALL MY EXTRA     * DOT01070
*                           EXTRA PROGRAMMING I DID TO HANDLE         * DOT01080
*                           NON-STANDARD LINE WIDTHS WENT TO NAUGHT.  * DOT01090
*                           I NOW ASSUME ALL TERMINALS SUPPORT THE    * DOT01100
*                           STANDARD 80 CHARACTER LINE WIDTH AND      * DOT01110
*                           WRITE THE MENU ACCORDINGLY.               * DOT01120
*                                                                     * DOT01130
*********************************************************************** DOT01140
         EJECT                                                          DOT01150
         PRINT GEN,NODATA                                               DOT01160
DOTERM   CSECT                                                          DOT01170
         USING ICDATA,R2      USE R2 TO ADDRESS ICATS COMMON DATA AREA  DOT01180
         USING CBTERM,R3      USE R3 TO ADDRESS TERMINAL CONTROL BLOCK  DOT01190
         USING CBUTS,R4       USE R4 TO ADDRESS UTS CONTROL BLOCK       DOT01200
         USING *,R15      USE R15 FOR BASE REG NEXT INSTRUCTION ONLY    DOT01210
         STM   R0,R14,REGSAVE       SAVE CALLER'S REGISTERS             DOT01220
         DROP  R15                                                      DOT01230
         USING DOTERM,R11           R11 WILL BE BASE REGISTER           DOT01240
         LR    R11,R15              ESTABLISH BASE REGISTER             DOT01250
*                                                                       DOT01260
*    LOOP THROUGH THE TERMCB CHAIN TO SEE WHICH TERMINAL NEEDED         DOT01270
*    SERVICING. IT'LL BE THE ONE WITH THE INTERRUPT-IS-IN FLAG          DOT01280
*    TURNED ON.                                                         DOT01290
         L     R3,TERM1ST          GET ADDRESS OF FIRST TERMCB          DOT01300
LOOPA    LTR   R3,R3               ARE WE PAST THE END-OF-CHAIN ??      DOT01310
         BZ    NOTFOUND            YEP, A NEEDY TERMINAL WASN'T FOUND   DOT01320
         TM    CBTERMFA,INTISIN    ELSE, SEE IF THIS ONE'S IN NEED      DOT01330
         BO    GOTIT               YEP, IT IS.  GO SERVICE HIM.         DOT01340
         L     R3,CBTERMFP         HAVEN'T FOUND A NEEDY UTS YET.       DOT01350
         B     LOOPA               GO CHECK THE NEXT ONE.               DOT01360
*                                                                       DOT01370
*  COME HERE WHEN THERE'S NO TERMINAL OUT THERE THAT NEEDS TO BE        DOT01380
*  SERVICED.  THIS'LL HAPPEN AFTER WE'VE JUST GOT THROUGH SERVICING     DOT01390
*  ONE AND AN INTERRUPT FROM ANOTHER TERMINAL HAS NOT COME IN YET       DOT01400
*  (NORMAL CASE).                                                       DOT01410
NOTFOUND DS    0H                                                       DOT01420
         NI    FLAGA,ALL-TERMINT   RESET TERMINAL INTERRUPT IS IN FLAG  DOT01430
         SSM   ENABSSM             TURN INTERRUPTS BACK ON              DOT01440
         B     TERMQUIT            RETURN TO ICATS MAINLINE             DOT01450
*                                                                       DOT01460
*  WE'VE FOUND A TERMINAL THAT NEEDS SERVICING.  THE ADDRESS OF         DOT01470
*  HIS TERMINAL CONTROL BLOCK IS IN R3.  LET'S GO SERVICE HIM.          DOT01480
*  FIRST LET'S PUT AN ENTRY INTO THE TRACE TABLE.                       DOT01490
*  SEE WHICH STATE THIS TERMINAL IS IN RIGHT NOW.                       DOT01500
GOTIT    DS    0H                                                       DOT01510
         LA    R8,CBTERMEA                                              DOT01520
         LA    R9,CBTERMCS                                              DOT01530
         LINEDIT TEXT='SERVICING TERMINAL ..., CSW = .................'-DOT01540
               ,SUB=(CHARA,(R8),HEX4A,(R9)),DISP=NONE,BUFFA=MENUUTS,REN-DOT01550
               T=NO                                                     DOT01560
*        LINEDIT TEXTA=MENUUTS           DEBUG CODE                     DOT01570
         ETTE  MENUUTS                                                  DOT01580
         SSM   ENABSSM             TURN INTERRUPTS BACK ON              DOT01590
         OI    CBTERMFA,IGOTIT         I'M GETTING SERVICED             DOT01600
         MVI   CBTERMSN,X'00'          INITIALIZE SENSE BYTE            DOT01610
         TM    CBTERMCS+4,X'02'        UNIT CHECK POSTED ??             DOT01620
         BNO   CON50                   NO, DIDN'T THINK IT WOULD BE.    DOT01630
         LA    R5,CBTERMSN                INSERT ADDRESS OF WHERE TO    DOT01640
         STCM  R5,B'0111',SENSECCW+1      PUT THE SENSE DATA INTO       DOT01650
         LA    R1,SENSECCW                GET ADDRESS OF SENSE CCW      DOT01660
         L     R15,ATERMIO        GET ADDRESS OF TERMINAL I/O ROUTINE   DOT01670
         BALR  R14,R15            DO THE SENSE TO THE TERMINAL          DOT01680
         LA    R9,CBTERMEA                                              DOT01690
         LA    R10,CBTERMSN-3                                           DOT01700
         LINEDIT TEXT='I GOT AN ASYNCHROUNOUS UNIT CHECK INTERRUPT FROM-DOT01710
                A DIALED TERMINAL.  ADDRESS = ..., SENSE DATA = ..',SUB-DOT01720
               =(CHARA,(R9),HEXA,(R10)),RENT=NO                         DOT01730
         B     DROPHIM                                                  DOT01740
CON50    TM    CBTERMFA,PLUGGED    IS HE PLUGGED IN TO A UTS ALREADY ?? DOT01750
         BNO   NOTPLUGD            NOPE, GO TRY TO PLUG HIM IN.         DOT01760
*                                                                       DOT01770
*    THIS TERMINAL IS ALREADY PLUGGED IN TO A UTS (NORMAL CASE).        DOT01780
*    BEFORE WE PASS THE INTERRUPT ON TO THE UTS, LET'S SEE IF HE        DOT01790
*    WANTS OUT.  DO A READ MODIFIED AND CHECK FOR HIS SESSION           DOT01800
*    TERMINATE STRING (USUALLY 4 POUND SIGNS UNLESS HE CHANGED IT).     DOT01810
         XC    CBTERMDC,CBTERMDC                                        DOT01820
         NI    CBTERMFA,ALL-DATAVALD    RESET DATA IS VALID SWITCH      DOT01830
         L     R5,ABUFFER         INSERT ADDRESS OF WHERE TO PUT THE    DOT01840
         STCM  R5,B'0111',READMCCW+1    READ MODIFIED DATA INTO         DOT01850
         LA    R1,READMCCW        GET ADDRESS OF READ MODIFIED CCW      DOT01860
         L     R15,ATERMIO        GET ADDRESS OF TERMINAL I/O ROUTINE   DOT01870
         BALR  R14,R15            DO THE PLUGGED-IN READ MODIFIED I/O   DOT01880
         LTR   R10,R15                                                  DOT01890
         BZ    CON100             IF ALL OK, CONTINUE ON                DOT01900
         LINEDIT TEXT='I GOT A BAD RETURN CODE DOING THE READ MODIFIED -DOT01910
               CCW. RC = ....',SUB=(DEC,(R10)),RENT=NO                  DOT01920
         B     DROPHIM            EXIT                                  DOT01930
CON100   DS    0H                                                       DOT01940
         CH    R0,=H'100'     DID I GET TOO MUCH READ MODIFIED DATA TO  DOT01950
         BH    CON120         FIT INTO THE TERMINAL CB'S BUFFER ??      DOT01960
*                             IF SO, DON'T MOVE DATA INTO TERM CB.      DOT01970
         OI    CBTERMFA,DATAVALD      BUFFER DATA IS NOW VALID          DOT01980
         STH   R0,CBTERMDC    SAVE LENGTH FOR FUTURE READ MOD FROM UTS  DOT01990
         LA    R6,CBTERMRM                                              DOT02000
         LA    R7,100         LENGTH OF READ MODIFIED BUFFER IN TERM CB DOT02010
         L     R8,ABUFFER                                               DOT02020
         LR    R9,R0                                                    DOT02030
         LA    R9,0(R9)       CLEAR PAD BYTE TO HEX ZERO                DOT02040
         MVCL  R6,R8          MOVE READ MODIFIED DATA TO TERM CB BUFFER DOT02050
CON120   DS    0H                                                       DOT02060
*    NOW SEE IF ANY OF THE MODIFIED FIELDS                              DOT02070
*    CONTAIN HIS SESSION TERMINATE STRING.                              DOT02080
         L     R6,ABUFFER         GET END OF READ MODIFIED DATA         DOT02090
         AR    R6,R0                                                    DOT02100
         L     R5,ABUFFER         GET BEGINNING OF READ MODIFIED DATA   DOT02110
         LA    R5,2(R5)           BUMP PAST FIRST FEW GARBAGE BYTES     DOT02120
         CH    R0,=H'7'      MUST HAVE AT LEAST 7 BYTES OF DATA ELSE    DOT02130
         BL    GIVE2UTS      NO WAY CAN WE HAVE THE TERMINATE STRING.   DOT02140
*    THERE IS A CASE WHERE THE READ MODIFIED DATA CAN CONTAIN THE       DOT02150
*    SESSION TERMINATE STRING WITHOUT A SET BUFFER ADDRESS (X'11')      DOT02160
*    ORDER IN FRONT OF IT.  THAT'S WHEN THE SCREEN IS CLEARED AND       DOT02170
*    THE GUY TYPES IN HIS S.T.S.  THEN THE S.T.S. IS RIGHT AFTER        DOT02180
*    THE AID BYTE AND THE CURSOR ADDRESS.                               DOT02190
         CLC   CBTERMST,1(R5)    IS IT SPECIAL CASE DESCRIBED ABOVE ??  DOT02200
         BE    CON180            YEP, BRANCH.                           DOT02210
LOOPB    DS    0H                                                       DOT02220
         CR    R5,R6                                                    DOT02230
         BNL   GIVE2UTS           GET OUT OF THIS LOOP                  DOT02240
         LA    R5,1(R5)           GO TO NEXT CHARACTER                  DOT02250
         CLI   0(R5),X'11'        IS IT THE START FIELD CHARACTER ??    DOT02260
         BNE   LOOPB              NOPE, CHECK NEXT CHARACTER            DOT02270
         LA    R5,3(R5)        BUMP PAST START FIELD & BUFFER ADDRESS   DOT02280
         CLC   CBTERMST,0(R5)  IS THIS HIS SESSION TERMINATE STRING ??  DOT02290
         BNE   LOOPB           NOPE, CONTINUE ON 'TILL END OF DATA      DOT02300
CON180   DS    0H                                                       DOT02310
*    THIS TERMINAL WAS PLUGGED IN TO A UTS AND WE FOUND HIS SESSION     DOT02320
*    TERMINATE STRING IN A MODIFIED FIELD.  THIS USER MUST WANT TO BE   DOT02330
*    BE DROPPED FROM THE UTS AND SENT BACK TO THE MENU.                 DOT02340
*    1)  INFORM THE UTS THAT WE'RE DROPPING THIS TERMINAL BY FAKING     DOT02350
*        A UNIT CHECK AND INTERVENTIO                                   DOT02360
*    2)  RESET BITS IN HIS TERMINAL FLAG.                               DOT02370
*    3)  SET THE MENU MESSAGE = "YOU WANTED OUT, YOU GOT OUT."          DOT02380
*    4)  GO GIVE HIM THE MENU                                           DOT02390
         XC    PARM0(128),PARM0     INITIALIZE REPLY CONTROL BLOCK.     DOT02400
         MVC   PARM0(3),CBTERMEA    GIVE THIS TERMINAL'S EBCDIC ADDRESS DOT02410
         MVC   PARM0+3(5),=CL5' '   PAD THE REST WITH BLANKS            DOT02420
         MVC   PARM1,=CL8'TERMIO'   IDENTIFY AS A TERMINAL INTERRUPT    DOT02430
         MVC   PARM15+3(2),=X'4006'     GIVE SENSE BYTE & CSW STATUS    DOT02440
         LA    R0,128                                                   DOT02450
         LA    R1,PARM0                                                 DOT02460
         L     R4,CBTERMUP                                              DOT02470
         ST    R4,THISUTS          THE UTS WRITE ROUTINE EXPECTS THIS   DOT02480
*                                  TO BE SET, SO .......                DOT02490
         L     R15,AINTUTS          TELL THE UTS THAT THIS TERMINAL IS  DOT02500
         BALR  R14,R15              BEING DROPPED.  IGNORE ANY ERRORS.  DOT02510
         NI    CBTERMFA,ALL-INTISIN-PLUGGED-DATAVALD                    DOT02520
         MVC   MENUMSG,=CL40'YOU WANTED OUT, YOU GOT OUT.'              DOT02530
         B     GIVEMENU                                                 DOT02540
*    WE DIDN'T FIND HIS SESSION TERMINATE STRING (NORMAL CASE), SO      DOT02550
*    WE'VE GO TO GO AHEAD AND PASS THIS INTERRUPT ALONG TO THE UTS.     DOT02560
*    OR WE BRANCHED HERE FROM DOWN BELOW TO PASS A DEVICE END           DOT02570
*    INTERRUPT ON TO THE UTS WHEN THIS GUY FIRST PLUGS IN.              DOT02580
GIVE2UTS DS    0H                                                       DOT02590
         XC    PARM0(128),PARM0     INITIALIZE REPLY CONTROL BLOCK.     DOT02600
         MVC   PARM0(3),CBTERMEA    GIVE THIS TERMINAL'S EBCDIC ADDRESS DOT02610
         MVC   PARM0+3(5),=CL5' '   PAD THE REST WITH BLANKS            DOT02620
         MVC   PARM1,=CL8'TERMIO'   IDENTIFY AS A TERMINAL INTERRUPT    DOT02630
         TM    CBTERMFA,PLUGGED                                         DOT02640
         BNO   CON190                                                   DOT02650
         MVI   PARM15+3,X'00'           FAKE ZERO SENSE BYTE            DOT02660
         MVC   PARM15+4(2),=X'8000'     FAKE ATTENTION CSW STATUS       DOT02670
         B     CON195                                                   DOT02680
CON190   DS    0H                                                       DOT02690
         OI    CBTERMFA,PLUGGED    REMEMBER THIS TERMINAL IS PLUGGED IN DOT02700
         MVI   PARM15+3,X'00'             FAKE ZERO SENSE               DOT02710
         MVC   PARM15+4(2),=X'0400'       FAKE DEVICE END STATUS        DOT02720
CON195   DS    0H                                                       DOT02730
         LA    R0,128                                                   DOT02740
         LA    R1,PARM0                                                 DOT02750
         L     R15,AINTUTS                                              DOT02760
         L     R4,CBTERMUP                                              DOT02770
         ST    R4,THISUTS          THE UTS WRITE ROUTINE EXPECTS THIS   DOT02780
*                                  TO BE SET, SO .......                DOT02790
*    FOR NOW, JUST FAKE GIVING THE INTERRUPT TO THE UTS.                DOT02800
*        OI    FLAGC,FAKEINT                                            DOT02810
         BALR  R14,R15                                                  DOT02820
*        NI    FLAGC,ALL-FAKEINT            RESET FAKE INTERRUPT BIT.   DOT02830
         LTR   R15,R15             DID THE WRITE GO OK ??               DOT02840
         BZ    TERMBYE             YEP, IT BETTER HAVE.                 DOT02850
         MVC   MENUMSG,=CL40'SORRY, UTS WRITE ERROR.  CSW = XXXX'       DOT02860
         LH    R1,CBUTSCSW         CONVERT THE LAST CSW STATUS FROM     DOT02870
         L     R15,ACONEHEX        THIS UTS INTO HEXADECIMAL EBCDIC     DOT02880
         BALR  R14,R15             AND PUT IT INTO THE MENU MESSAGE     DOT02890
         STCM  R1,B'1111',MENUMSG+31                                    DOT02900
         NI    CBTERMFA,ALL-PLUGGED-DATAVALD     RESET THIS TERMINAL.   DOT02910
         B     GIVEMENU                                                 DOT02920
         EJECT                                                          DOT02930
*********************************************************************** DOT02940
*    THIS TERMINAL IS NOT PLUGGED IN YET.  IT MUST BE IN ONE TWO      * DOT02950
*    STATES.  EITHER HE HASN'T SEEN A MENU, IN WHICH CASE WE'LL       * DOT02960
*    THROW ONE UP FOR HIM, OR HE'S LOOKING AT A MENU NOW, AND HE'S    * DOT02970
*    JUST HIT ENTER (OR SOMETHING) AND NOW WE'VE GOT TO FIGURE OUT    * DOT02980
*    WHAT HE WANTS US TO DO.                                          * DOT02990
*********************************************************************** DOT03000
NOTPLUGD DS    0H                                                       DOT03010
         MVC   MENUMSG,=CL40' '    BLANK OUT MENU MESSAGE JUST IN CASE  DOT03020
         TM    CBTERMFA,MENUUP     IS HE LOOKING AT A MENU RIGHT NOW ?? DOT03030
         BO    CON200              YEP, GO SEE WHAT HE WANTS TO DO.     DOT03040
*    THIS TERMINAL MUST HAVE BEEN JUST DIALED UP TO US.  LET'S SEE      DOT03050
*    WHAT KIND OF TERMINAL IT IS - SPECIFICALLY, HOW WIDE IT IS.        DOT03060
         LH    R5,CBTERMHA                                              DOT03070
         DIAG  R5,R6,X'0024'                                            DOT03080
         LA    R5,80                  ASSUME 80 CHARACTER LINE WIDTH    DOT03090
*        C     R7,=X'40010500'        3278-5 IS THE ONLY TERMINAL WITH  DOT03100
*        BNE   SKIPONE                132 CHARACTERS PER LINE.          DOT03110
*        LA    R5,132                                                   DOT03120
SKIPONE  STH   R5,CBTERMLL                                              DOT03130
         B     GIVEMENU               NOW GO GIVE HIM A MENU.           DOT03140
*                                                                       DOT03150
CON200   DS    0H                                                       DOT03160
         L     R5,ABUFFER         INSERT ADDRESS OF WHERE TO PUT THE    DOT03170
         STCM  R5,B'0111',READMCCW+1    READ MODIFIED DATA INTO         DOT03180
         LA    R1,READMCCW        GET ADDRESS OF READ MODIFIED CCW      DOT03190
         L     R15,ATERMIO        GET ADDRESS OF TERMINAL I/O ROUTINE   DOT03200
         BALR  R14,R15            DO THE MENU READ MODIFIED I/O         DOT03210
         LTR   R10,R15                                                  DOT03220
         BZ    CON210             IF ALL OK, CONTINUE ON                DOT03230
         LINEDIT TEXT='I GOT A BAD RETURN CODE DOING THE READ MENU CCW.-DOT03240
                 RC = ....',SUB=(DEC,(R10)),RENT=NO                     DOT03250
         B     DROPHIM                                                  DOT03260
CON210   DS    0H                                                       DOT03270
         L     R5,ABUFFER                                               DOT03280
         CLI   0(R5),X'6C'        SEE IF HE HIT PA1 = LET ME OUT        DOT03290
         BE    DROPHIM            IF SO, UN-DIAL THIS TERMINAL          DOT03300
         MVC   MENUMSG,=CL40'ONLY THE PA1 OR ENTER KEYS WORK'           DOT03310
         CLI   0(R5),X'7D'        SEE IF HE HIT THE ENTER KEY           DOT03320
         BNE   GIVEMENU           IF NOT, HE HIT AN INVALID KEY.        DOT03330
*    CHECK FOR 1ST MODIFIED FIELD BEING THE SESSION TERMINATE STRING.   DOT03340
         CH    R0,=H'6'        INSURE WE GOT AT LEAST 6 BYTES DATA      DOT03350
         BL    CON300          IF NOT, THERE WERE NO MODIFIED FIELDS.   DOT03360
         CLC   3(3,R5),=X'11C14A'                                       DOT03370
*    X'11' = SET BUFFER ADDRESS.  X'C14A' = WHERE THE STS WAS PUT.      DOT03380
         BNE   CON300             IF IT'S NOT, CONTINUE ON.             DOT03390
*    VALIDATE THE SESSION TERMINATE STRING.  DON'T LET IT BE LESS THAN  DOT03400
*    FOUR CHARACTERS LONG.                                              DOT03410
         MVC   MENUMSG,=CL40'TERMINATE STRING MUST BE EXACTLY 4 CHARS'  DOT03420
         CH    R0,=H'10'          INSURE WE GOT AT LEAST 10 BYTES DATA  DOT03430
         BL    GIVEMENU           IF NOT, GIVE HIM AN ERROR MESSAGE.    DOT03440
         CLI   6(R5),X'11'                                              DOT03450
         BE    GIVEMENU                                                 DOT03460
         CLI   7(R5),X'11'                                              DOT03470
         BE    GIVEMENU                                                 DOT03480
         CLI   8(R5),X'11'                                              DOT03490
         BE    GIVEMENU                                                 DOT03500
         CLI   9(R5),X'11'                                              DOT03510
         BE    GIVEMENU                                                 DOT03520
*    OK, IT'S GOOD.  LET'S SAVE THE NEW SESSION TERMINATE STRING.       DOT03530
         MVC   CBTERMST,6(R5)                                           DOT03540
CON300   DS    0H                                                       DOT03550
*    NOW LET'S DETERMINE WHICH UTS HE WANTS TO CONNECT TO.              DOT03560
*    THE CURSOR POSITION IS IN THE SECOND AND THIRD BYTES OF THE        DOT03570
*    READ MODIFIED BUFFER.  IT'S COMPRISED OF 2 NUMBERS IN BIT          DOT03580
*    POSITIONS X'3F' OF BOTH BYTES (I.E. THE TWO HIGH ORDER BITS OF     DOT03590
*    BOTH BYTES ARE JUNK).  THIS ALGORITHM TAKES THOSE 2 BYTES AND      DOT03600
*    CONVERTS THEM INTO ROW NUMBER (0-23) AND COLUMN NUMBER (0-79).     DOT03610
         SR    R8,R8                                                    DOT03620
         ICM   R8,B'0011',1(R5)       GET CURSOR ADDRESS                DOT03630
         N     R8,=X'00003F3F'        STRIP OFF EXTRA BITS              DOT03640
         SRDL  R8,8                   SEPARATE THE 2 HALVES             DOT03650
         SLL   R9,2                                                     DOT03660
         SRDL  R8,26                  COMBINE 2 HALVES AGAIN IN R9      DOT03670
         LH    R1,CBTERMLL    DIVIDE CURSOR POSITION BY THE LINE        DOT03680
         DR    R8,R1          LENGTH.  R8 = COLUMN, R9 = ROW.           DOT03690
*    LET'S NOW TRY TO CORRESPOND THIS LINE NUMBER TO A REAL UTS.        DOT03700
         L     R4,CBFIRST         GET ADDRESS OF FIRST UTS CB           DOT03710
         LTR   R4,R4              LOAD DOESN'T SET THE CONDITION CODE   DOT03720
         BZ    CON400             CHECK FOR NO UTS'S AT ALL             DOT03730
         LA    R8,2                                                     DOT03740
         B     CON350   SKIP THE NEXT 3 INSTRUCTIONS FIRST TIME THROUGH DOT03750
UTSLOOP  DS    0H                                                       DOT03760
         L     R4,CBUTSFP         POINT TO NEXT UTS CONTROL BLOCK       DOT03770
         LTR   R4,R4              LOAD DOESN'T SET THE CONDITION CODE   DOT03780
         BZ    BADLINE            ERROR IF NO MORE.                     DOT03790
CON350   DS    0H                                                       DOT03800
         LA    R8,2(R8)                                                 DOT03810
         CH    R8,=H'23'          CHECK FOR OFF THE SCREEN.             DOT03820
         BH    BADLINE                                                  DOT03830
         CR    R8,R9              IS THIS THE UTS HE WANTED ??          DOT03840
         BE    GOTIT2             YEP, CONTINUE ON.                     DOT03850
         BL    UTSLOOP      IF NOT PAST CURSOR POSITION, KEEP CHECKING  DOT03860
BADLINE  DS    0H                                                       DOT03870
         MVC   MENUMSG,=CL40'INVALID CURSOR POSITION.'                  DOT03880
         B     GIVEMENU                                                 DOT03890
*    HIS CURSOR WAS ON A VALID LINE AND R3 IS POINTING TO THE UTS       DOT03900
*    CONTROL BLOCK OF THE UTS HE WANTS TO GET PLUGGED INTO.  LET'S      DOT03910
*    SEE IF THAT UTS WAS ONLINE LAST TIME I CHECKED.                    DOT03920
GOTIT2   DS    0H                                                       DOT03930
         TM    CBUTSFGA,ONLINE     IF IT'S PLUGGED IN, THEN             DOT03940
         BO    PLUGIMIN            GO PLUG HIM IN TO THIS UTS.          DOT03950
         L     R15,=V(ATTACH)      ELSE GO TRY TO GET HIM ONLINE.       DOT03960
         BALR  R14,R15                                                  DOT03970
         TM    CBUTSFGA,ONLINE     DID THAT WORK ??  IF SO, THEN        DOT03980
         BO    PLUGIMIN            GO PLUG HIM IN TO THE UTS.           DOT03990
         MVC   MENUMSG,=CL40'SORRY, THAT UTS WON''T COME ONLINE.'       DOT04000
         B     GIVEMENU            ELSE GIVE MSG THAT WE FAILED         DOT04010
PLUGIMIN DS    0H                                                       DOT04020
         ST    R4,CBTERMUP         REMEMBER WHICH UTS THIS              DOT04030
*                                  TERMINAL IS PLUGGED IN TO.           DOT04040
         B     GIVE2UTS                                                 DOT04050
*********************************************************************** DOT04060
GIVEMENU DS    0H                                                       DOT04070
         MVC   MENUSTS,CBTERMST                                         DOT04080
         SR    R0,R0                                                    DOT04090
         LA    R1,1              SECOND LINE, FIRST POSITION            DOT04100
         BAL   R14,CONVSBA                                              DOT04110
         STCM  R1,B'0011',MENUSBA1                                      DOT04120
         SR    R0,R0                                                    DOT04130
         LA    R1,2              THIRD LINE, FIRST POSITION             DOT04140
         BAL   R14,CONVSBA                                              DOT04150
         STCM  R1,B'0011',MENUSBA2                                      DOT04160
         LA    R0,50                                                    DOT04170
         LA    R1,23             LAST (24TH) LINE, FAR RIGHT            DOT04180
         BAL   R14,CONVSBA                                              DOT04190
         STCM  R1,B'0011',MENUSBA3                                      DOT04200
         LA    R0,1                                                     DOT04210
         LA    R1,4              CURSOR ON 5TH LINE, SECOND POSITION    DOT04220
         BAL   R14,CONVSBA                                              DOT04230
         STCM  R1,B'0011',MENUSBA4                                      DOT04240
         LA    R5,MENUMSGL       INITIALIZE LENGTH OF MENU DATA         DOT04250
         LA    R6,MENUUTS        BEGINNING OF UTS DATA ON MENU          DOT04260
         LA    R7,4              PUT FIRST UTS ON SCREEN LINE 5 (0-N)   DOT04270
         L     R4,CBFIRST                                               DOT04280
         LTR   R4,R4             CHECK FOR NO UTS'S AT ALL              DOT04290
         BNZ   CON500                                                   DOT04300
CON400   MVC   MENUMSG,=CL40'SORRY, BUT THERE ARE NO UTS''S TO GO TO.'  DOT04310
         B     DOMENUIO                                                 DOT04320
CON500   DS    0H                                                       DOT04330
*    WE'VE GOT A UTS TO PUT ON THE SCREEN.  CONVERT THIS LINE NUMBER    DOT04340
*    TO A SCREEN BUFFER ADDRESS.                                        DOT04350
         MVI   0(R6),X'11'                                              DOT04360
         SR    R0,R0           FIRST POSITION ON LINE                   DOT04370
         LR    R1,R7           THIS LINE NUMBER                         DOT04380
         BAL   R14,CONVSBA                                              DOT04390
         STCM  R1,B'0011',1(R6)    STORE BUFFER ADDRESS                 DOT04400
         MVC   3(2,R6),=X'1D40'    ASSUME IT'S OFFLINE                  DOT04410
         TM    CBUTSFGA,ONLINE     DID I GUESS RIGHT ??                 DOT04420
         BNO   SKIP1               YEP.  BRANCH IF IT'S OFFLINE.        DOT04430
         MVI   4(R6),X'C8'         REPLACE WITH HIGHLIGHT ATTRIBUTE     DOT04440
SKIP1    MVC   5(8,R6),CBUTSUID                                         DOT04450
         MVC   13(12,R6),=C' AT ADDRESS '                               DOT04460
         LH    R1,CBUTSRAD                                              DOT04470
         L     R15,ACONEHEX                                             DOT04480
         BALR  R14,R15                                                  DOT04490
         STCM  R1,B'0111',25(R6)                                        DOT04500
         MVC   28(2,R6),=X'1D60'  DELIMIT THIS LINE                     DOT04510
         LA    R5,30(R5)          BUMP TOTAL BYTES IN MENU BUFFER       DOT04520
         LA    R6,30(R6)          BUMP MENU BUFFER POINTER              DOT04530
         LA    R7,2(R7)           PUT NEXT UTS 2 LINES DOWN             DOT04540
         C     R7,=F'23'          ARE WE AT THE END OF THE SCREEN ??    DOT04550
         BH    DOMENUIO           IF SO, DON'T ADD ANYMORE UTS'S.       DOT04560
         L     R4,CBUTSFP         ELSE, GET POINTER TO NEXT UTS CB      DOT04570
         LTR   R4,R4         IF THERE'S ANOTHER UTS TO PUT              DOT04580
         BNZ   CON500        ON THE SCREEN, GO DO IT.                   DOT04590
DOMENUIO DS    0H                                                       DOT04600
         OI    CBTERMFA,MENUUP        REMEMBER THAT HE'S SEEN A MENU    DOT04610
         STCM  R5,B'0111',LENGTH                                        DOT04620
         LR    R7,R5                                                    DOT04630
         SH    R7,=H'258'                                               DOT04640
         C     R7,=X'000000FF'                                          DOT04650
         BNH   RICK2                                                    DOT04660
         LA    R7,255                                                   DOT04670
RICK2    IC    R8,MENUUTS-1                                             DOT04680
         STC   R7,MENUUTS-1                                             DOT04690
         ETTE  MENUUTS-1                                                DOT04700
         STC   R8,MENUUTS-1                                             DOT04710
         LA    R1,WRITECCW        GET ADDRESS OF WRITE CCW              DOT04720
         L     R15,ATERMIO        GET ADDRESS OF TERMINAL I/O ROUTINE   DOT04730
         BALR  R14,R15            DO THE WRITE MENU I/O                 DOT04740
         LTR   R10,R15                                                  DOT04750
         BZ    TERMBYE            IF ALL OK, RETURN TO DISPATCHER       DOT04760
         LINEDIT TEXT='I GOT A BAD RETURN CODE DOING THE WRITE MENU CCW-DOT04770
               . RC = ....',SUB=(DEC,(R10)),RENT=NO                     DOT04780
         LM    R9,R10,CBTERMCS                                          DOT04790
         LINEDIT TEXT='CSW = ........ ........',SUB=(HEX,(R9),HEX,(R10)-DOT04800
               ),RENT=NO                                                DOT04810
*                                                                       DOT04820
DROPHIM  DS    0H                                                       DOT04830
*    ACCORDING TO A PHONE CONVERSATION WITH JEFF DOBBEK (6/22/83 AT     DOT04840
*    3:30), HE WANTS TO SEE AN ASYNCHRONOUS INTERRUPT WHENEVER I DROP   DOT04850
*    A TERMINAL.  PUT DEVICE END AND UNIT CHECK IN THE CSW STATUS AND   DOT04860
*    INTERVENTION REQUIRED IN THE SENSE BYTE.                           DOT04870
         TM    CBTERMFA,PLUGGED       WAS THIS TERMINAL PLUGGED IN ??   DOT04880
         BNO   CON600                 NO, DON'T HAVE TO TELL THE UTS.   DOT04890
         XC    PARM0(128),PARM0     INITIALIZE REPLY CONTROL BLOCK.     DOT04900
         MVC   PARM0(3),CBTERMEA    GIVE THIS TERMINAL'S EBCDIC ADDRESS DOT04910
         MVC   PARM0+3(5),=CL5' '   PAD THE REST WITH BLANKS            DOT04920
         MVC   PARM1,=CL8'TERMIO'   IDENTIFY AS A TERMINAL INTERRUPT    DOT04930
         MVC   PARM15+3(2),=X'4006'     GIVE SENSE BYTE & CSW STATUS    DOT04940
         LA    R0,128                                                   DOT04950
         LA    R1,PARM0                                                 DOT04960
         L     R4,CBTERMUP                                              DOT04970
         ST    R4,THISUTS          THE UTS WRITE ROUTINE EXPECTS THIS   DOT04980
*                                  TO BE SET, SO .......                DOT04990
         L     R15,AINTUTS          TELL THE UTS THAT THIS TERMINAL IS  DOT05000
         BALR  R14,R15              BEING DROPPED.  IGNORE ANY ERRORS.  DOT05010
CON600   DS    0H                                                       DOT05020
         MVI   CBTERMFA,X'00'                                           DOT05030
         MVC   CBTERMST,=CL4'$$$$'   DEFAULT SESSION TERMINATE STRING   DOT05040
         MVC   DROPCUU(3),CBTERMEA                                      DOT05050
         LA    R1,DROPCMD                                               DOT05060
         SVC   202                                                      DOT05070
         DC    AL4(*+4)                                                 DOT05080
TERMBYE  DS    0H                                                       DOT05090
         NI    CBTERMFA,ALL-INTISIN-IGOTIT THIS INTERRUPT TAKEN CARE OF DOT05100
TERMQUIT LM    R0,R14,REGSAVE                                           DOT05110
         BR    R14                  RETURN TO CALLER                    DOT05120
*                                                                       DOT05130
*    LOCAL SUBROUTINE TO CONVERT A SCREEN LINE NUMBER TO A SET          DOT05140
*    BUFFER ADDRESS.  EXAMPLE:  UPON ENTRY, IF R0 = 0 & R1 = 4,         DOT05150
*    THAT MEANS WHAT SET BUFFER ADDRESS DO I NEED TO USE TO START       DOT05160
*    THIS FIELD ON THE FIFTH LINE OF THE SCREEN (STARTS WITH            DOT05170
*    LINE 0), THE FIRST POSITION (ALSO STARTS WITH 0).  THE             DOT05180
*    ANSWER IS DEPENDENT ON THE SCREEN WIDTH (IN CBTERMLL) WHICH        DOT05190
*    IS USUALLY 80.  ASSUMING 80, THIS ROUTINE RETURNS R1 = 'C540'.     DOT05200
CONVSBA  DS    0H                                                       DOT05210
         MH    R1,CBTERMLL                                              DOT05220
         AR    R1,R0                                                    DOT05230
         SR    R0,R0                                                    DOT05240
         D     R0,=F'64'       R0 = LOW & R1 = HIGH ORDER DIGIT         DOT05250
         LR    R15,R0          USE R15 FOR IC INSTRUCTION-R0 WON'T WORK DOT05260
         IC    R0,FUNNYTBL(R15)       TRANSLATE LOW TO FUNNY DIGIT      DOT05270
         IC    R1,FUNNYTBL(R1)        TRANSLATE HIGH TO FUNNY DIGIT     DOT05280
         SLL   R1,8                   COMBINE HIGH AND LOW DIGITS       DOT05290
         OR    R1,R0                                                    DOT05300
         BR    R14             RETURN TO CALLER                         DOT05310
*    TERMINAL CCW'S.  ADDRESSES WILL BE FILLED IN LATER.                DOT05320
         DS    0D                                                       DOT05330
SENSECCW DC    X'0400000020000001'         SENSE CCW                    DOT05340
READMCCW DC    X'0600000020000FFF'         READ MODIFIED CCW            DOT05350
WRITECCW DC    X'05',AL3(MENUDATA),X'20'   WRITE CCW                    DOT05360
LENGTH   DC    X'000000'                   WRITE LENGTH                 DOT05370
WORKA    DS    D                 TEMPORARY WORK AREAS                   DOT05380
WORKB    DS    D                                                        DOT05390
DROPCMD  DC    CL8'CP'                                                  DOT05400
         DC    CL8'RESET'                                               DOT05410
DROPCUU  DC    CL8' '                                                   DOT05420
         DC    8X'FF'                                                   DOT05430
REGSAVE  DS    15F                                                      DOT05440
MENUDATA DC    X'C21140401D60'                                          DOT05450
MENUMSG  DC    CL40' '                                                  DOT05460
         DC    X'11406F'                                                DOT05470
         DC    C'SESSION TERMINATE STRING ='                            DOT05480
         DC    X'1DC8'           (X'1DC9' FOR MODIFIED)                 DOT05490
MENUSTS  DC    C'$$$$'                                                  DOT05500
         DC    X'11'                                                    DOT05510
MENUSBA1 DC    X'0000'                                                  DOT05520
         DC    X'1D60'                                                  DOT05530
         DC    C'POSITION THE CURSOR TO SELECT WHICH UTS TO CONNECT '   DOT05540
         DC    C'TO, THEN PRESS THE ENTER KEY'                          DOT05550
         DC    X'11'                                                    DOT05560
MENUSBA2 DC    X'0000'                                                  DOT05570
         DC    X'1D60'                                                  DOT05580
         DC    C'THE HIGHLIGHTED ONES WERE ONLINE LAST TIME I CHECKED'  DOT05590
         DC    X'11'                                                    DOT05600
MENUSBA3 DC    X'0000'                                                  DOT05610
         DC    C'TO LEAVE THIS SCREEN, HIT PA1'                         DOT05620
         DC    X'11'                                                    DOT05630
MENUSBA4 DC    X'0000'                                                  DOT05640
         DC    X'13'                                                    DOT05650
MENUMSGL EQU   *-MENUDATA                                               DOT05660
MENUUTS  DS    10CL30  X'1100001DC8',C'UTS1     AT ADDRESS XXX',X'1D60' DOT05670
*                                40 IF OFFLINE                          DOT05680
*    END OF MENU SCREEN DATA                                            DOT05690
FUNNYTBL DC    X'40C1C2C3C4C5C6C7C8C94A4B4C4D4E4F'                      DOT05700
         DC    X'50D1D2D3D4D5D6D7D8D95A5B5C5D5E5F'                      DOT05710
         DC    X'6061E2E3E4E5E6E7E8E96A6B6C6D6E6F'                      DOT05720
         DC    X'F0F1F2F3F4F5F6F7F8F97A7B7C7D7E7F'                      DOT05730
ENABSSM  DC    X'FF'             MASK TO ENABLE I/O & EXT. INTERRUPTS   DOT05740
         ICDATA                                                         DOT05750
         END                                                            DOT05760