*M*      RAS      REMOTE ASSIST STATION HANDLER FOR XEROX 560'S
*P*
*P*               THIS MODULE CONTAINS THE FOLLOWING EXTERNALLY
*P*               DEFINED ENTRY POINTS.
*P*
*P*      ROUTINE                    DESCRIPTION
*P*      -----------                ---------------------------------
*P*      RAS:                       MODULE BASE ADDRESS
*P*      RAS                        I/O PRE-PROCESSOR
*P*      RASCU                      I/O POST PROCESSOR
*P*      T:RESCNCT                  RESOURCE CONNECT ROUTINE - SCHED
*,*                                 CALLS TO CONNECT USER'S M:UC TO
*,*                                 THE RAS DEVICE.
*P*
 TITLE '** XEROX 560 REMOTE ASSIST STATION (RAS) HANDLER **'
RAS:     EQU      %
*    TABLE GENERATION DIRECTIVES
*
:DOT     COM,8,8,8,8       BA(AF(1))-BA(DOT),AF(2),AF(3),AF(4)
:CLST    COM,8             DA(AF(1))-DA(DOT)
:CDW     CNAME
         PROC
LF       EQU      %
         GEN,8,24 AF(1),AF(2)       GENERATE ORDER CODE AND BA/WA
         GEN,8,8,8,8  AF(3),X'80',AF(4),AF(5)
         PEND
         PAGE
MONPROC  SET      1
UTSPROC  SET      1
S69PROC  SET      1
UFLAGS   SET      1
         SYSTEM   UTS
*
*        REGISTER ASSIGNMENTS
*
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
R8       EQU      8
R9       EQU      9
R10      EQU      10
R11      EQU      11
R12      EQU      12
R13      EQU      13
R14      EQU      14
R15      EQU      15
         PAGE
*
*        INTERNAL REFERENCES
*
         REF      COMLIST         * BUILDS COMMAND LISTS FOR I/O
         REF      DCT1            * HALF-WORD TABLE OF DEVICE ADDRS
         REF      DCT13           * TABLE CONTAINING TDV STATUS DBL-WORD
         REF      DCT3            * DEVICE ERROR STATUS (SIO FAIL..ETC..)
         REF      DCT5            * CONTAINS DEVICE SWITCHES
         REF      DELCOM          * DEL CURRENT CDW RETURN POINT
         REF      DOUBLEONE       * DBL-WORD OF 1,1
         REF      DOUBLEZERO      * DLB-WORD OF 0,0
         REF      E:ABRT          * ABORT USER
         REF      E:CBK           * BREAK EVENT
         REF      E:CEC           * CONTROL-Y EVENT
         REF      IOQ5            * CURRENT FUNCTION STEP TABLE
         REF      IOQ6            * TABLE CONTAINING DCB ADDRESSES
         REF      IOQ8            * CONTAINS BUF BA/CDW POINTER
         REF      IOQ9            * CONTAINS BYT CNT/# OF CDW'S
         REF      IOQ11             * #OF RETRIES REMAINING
         REF      IOSCU           * HANDLER POST PROCESS RETURN
         REF      IOSERCK         * ROUTINE TO EXAMINE ERROR STATUS
         REF      J:JIT           * ADDRESS OF THE JIT
         REF      M:UC            * DCB IN THE JIT
         REF      MSG4            * 'NOT OPERATIONAL' MESSAGE
         REF      MSG2              * 'ERROR '
         REF      M16             * X'0000FFFF'
         REF      M17             * X'0001FFFF'
         REF      M24             * X'00FFFFFF'
         REF      NBYT2           * DATA X'FFFF00FF'
         REF      RAS:CBP         * LAST WORD OF RAS I/O TABLE
         REF      RAS:DOL         * HEAD OF TABLE FOR RAS I/O
         REF      SH:RNM          * RESOURCE NAME TABLE
         REF      T:DLR1          * RETURN POINT FOR T:RESCNCT
         REF      T:RUE           * REPORT UNUSUAL EVENT IN SCHED
         REF      UH:DL           * USER'S DO-LIST TABLE
         REF      UH:FLG          * USER FLAG HALF-WORD TABLE
         REF      USECOM          * USE CUR CDW RETURN IN HANDLERS
         REF      UX:JIT          * USER TABLE OF JIT PAGE #7S
         REF      XEOD            * BANG EOD TEXT STRING IN HANDLERS
         REF      YFF             * DATA X'FF000000'
         REF      Y04             * DATA X'04000000'
         REF      Y15             * DATA X'15000000'
         REF      Y2              * DATA X'20000000'
         REF      NB31TO0           * TIME OUT MASK 'FFFFFFEF'
         PAGE
*
*        EXTERNAL DEFINITIONS
*
         DEF      RAS               PRE-PROCESSOR
         DEF      T:RESCNCT
         DEF      RASCU             POST PROCESSOR
         DEF      RESCNCT           DEF IT FOR SCHED
         DEF      RAS:              FOR XDELTA TO FIND
         PAGE
*P*
*P*        RAS TABLES CONSTRUCTION
*P*
*P*
*P*0          8              15             23             31
*P*-----------------------------------------------------------*
*P* X'F4'     *       7      *         DCT INDEX            *
*P*           *              *                              *RAS:DOL WA
*P*-----------------------------------------------------------*
*P* BRK RCVD  *     T:RESCNCT WORD ADDRESS (PHONY ECB)      *
*P* COUNTER   *                                             *
*P*           *                                             *
*P*-----------------------------------------------------------*
*P* NEW LINE  * PROMPT       * # CHARACTERS *               *
*P* TO SEND IN * CHARACTER   * SENDT SO FAR *               *
*P* FRONT OF  * TO SEND      * ON CURRENT   *               *
*P* PROMPT CHAR * BEFORE READS * PRINT LINE *               *
*P*           *              *              *               *
*P*-----------------------------------------------------------*
*P* RAS USER  * RESOURCE     * BREAK        * NEW LINE IS   *
*P* NUMBER    * TABLE        * SIGNAL       * NOW REQUIRED  *
*P* (CP-V)    * INDEX        * HAS BEEN     * BEFORE NEXT   *RAS:CBP WA
*P* (TABLES)  *              * SENT ALREADY * WRITE         *
*P*           *              *              *               *
*P*-----------------------------------------------------------*
*P*
         PAGE
*F*
*F*      NAME:    RAS
*F*
*F*      PURPOSE:
*F*               INPUT/OUTPUT PRE-PROCESS ROUTINE
*F*
*F*      DESCRIPTION:
*F*               IOQ CALLS WITH THE STANDARD I/O REGISTER SETUP IN
*F*               R0-R1-R2-R3. RAS WILL SCAN THE I/O BUFFER TO
*F*               REMOVE TRAILING BLANKS - ADD THE PROMPT CHARACTER
*F*               COMMAND DBL-WORD - OR SEND THE NEW LINE PRIOR
*F*               TO THE WRITE .
*F*
RAS      EQU      %
         BAL,R8   RAS:SET         * CHECK FOR BREAK SETUP
         LB,R7    IOQ5,R3         * GET CURRENT FUNCTION STEP
         LB,R7    MCVPRE,R7       * GET LOC OF PRE-HANDLER
         BAL,R9   RAS,R7          * DISPATCH TO PRE-PROCESS ROUTINE
RAS1     EQU      %               * COME HERE IF NONE
         LW,R4    Y2              * HOLD  CHANNEL/RESTRICT ADDRS TO DCT1
         BAL,R10  COMLIST         * GO BACK TO COMLIST
         PAGE
*
*        DEVICE OPERATION TABLE (DOT) FOR THE REMOTE ASSIST STATION
*
DOT      SET      %
         :DOT     TYRE,255,3,2   <0>* READ FUNCTION
         :DOT     TYWD,4,4,2     <1>* WRIT FUNCTION
         :DOT     TYNL,2,2,2     <2>* NEW LINE
         :DOT     TYNL,1,0,0     <3>* ERROR RCVRY FOR READ
         :DOT     TYNL,1,1,1     <4>* ERROR RCVRY FOR WRIT
         PAGE
*
*        POINTERS TO THE SKELETON COMMAND DOUBLE-WORDS
*
TYRE     :CLST    WRPROM            ALL READS GET PROMPT CHAR FIRST
         :CLST    RDTYE             AND THEN THE READ GOES OUT
*
TYWD     :CLST    WRNL              WRITE NEW LINE PRIOR TO WRITING
         :CLST    WRBUF             THE BUFFER OUT
*
*
TYNL     :CLST    TNL
         PAGE
*
*        SKELETON COMMAND DOUBLE WORDS FOR RAS I/O
*
         BOUND    8
*
FNC      EQU      X'1E'             ICE,HTE,IUE,SIL (NO COMMAND CHAIN)
FC       EQU      X'2E'             ICE,HTE,IUE,SIL (COMMAND CHAIN)
*
WRNL     :CDW     5,NLCHK,FC,4,1    NEW LINE BEFORE BUF WRITE CDW
*
WRBUF    :CDW     5,0,FNC,2,0     BUFFER WRITE CDW
*
WRPROM   :CDW     5,TELCHK,FC,4,1   SPECIAL HANDLER FUNCTION/CNT=1
*
RDTYE    :CDW     134,0,FNC,2,0     READ TYPEWRITER WITH CONTROL
*
TYB      :CDW     20,0,0,0,0        SET BREAK WATCH
*
TNL      :CDW     5,BA(Y15),FNC,0,1 WRITE NEW LINE
         PAGE
*
*        POST PROCESSING VECTOR BASED UPON CURRENT FUNCTION STEP
*
MCVT     COM,8    AF(1)-RAS
*
MCVPOST  EQU      %
         MCVT     RASCU1            READ: CLEANUP
         MCVT     RASCU7            WRIT: RETURN TO IOQ IF NO ERRORS
         MCVT     RASCU7            NL:   EXIT
         MCVT     RASRTRY           RDER: RETRY ORIG
         MCVT     RASRTRY           WRER: RETRY ORIG
         BOUND    4
         PAGE
*
*        PRE-PROCESSING VECTOR BASED UPON CURRENT FUNCTION STEP
*
MCVPRE   EQU      %
         MCVT     RAS1            0 = READ NEEDS NO PRE-PROCESS
         MCVT     RAS:PRE         1 = WRIT NEEDS PRE-PROCESSING
         MCVT     RAS1            2 = NEW LINE NEEDS NO PRE-PROCESS
         MCVT     RAS1            3 = ERR RCVRY FOR READ
         MCVT     RAS1            4 = ERR RCVRY FOR WRIT
         BOUND    4
*
         PAGE
*F*
*F*      NAME:    RASCU
*F*
*F*      PURPOSE:
*F*               TO PERFORM ERROR ANALYSIS/CLEANUP FROM THE
*F*               I/O EVENT THAT JUST OCCURED.
*F*
*F*      DESCRIPTION:
*F*               IOQ HAS CALLED WITH THE STANDARD I/O REGISTER
*F*               SETUP IN R0-R1-R2-R3.
*F*
*F*               RASCU WILL CHECK STATUS FOR AN ERROR - IF
*F*               SO IT WILL RE-INITIATE THE I/O EVENT WITH ERROR
*F*               RECOVERY.
*F*
*F*               IF NOT IT WILL PROCESS THE BUFFER FOR DELETED CHARS
*F*               DELETED LINES AND RETURN THE BUFFER TO THE USER
*F*               AS IT SHOULD BE.
*F*
         B        RASBRK          * ENTRY FOR UNSOLICITED BREAK FROM
*                                 * IOINT IN IOQ.
*
RASCU    EQU      %
         LB,R9    DCT3,R1         * GET DEVICE  FLAGS
         CI,R9    X'18'           * DID SIO FAIL/DEVICE TIMEOUT
         BANZ     RAS:ERR         * YUP-ABORT THE USER
         BAL,R9   IOSERCK         * EXAMINE STATUS FOR AN ERROR
         B        RASRTRY         * RETRY THE OPERATION IF ERROR
         CW,R5    Y2              * CHECK AIO STATUS FOR BREAK HIT
         BANZ     BREAK           * YUP - REPORT IT TO SCHED
         LB,R6    IOQ5,R3         * GET CURRENT FUNCTION STEP
         LB,R7    MCVPOST,R6      * GET VECTOR VALUE
         B        RAS,R7          * DISPATCH PROPER ROUTINE
RASCU1   EQU      %               *
         LD,R10   DCT13,R1        * GET TDV STATUS DBL-WORD
         AND,R10  M17             * MASK CDW POINTER
         AND,R11  M16             * MASK RBC FIELD
         LB,R6    RAS:CBP         * GET USER'S #
         LOAD,R8  UX:JIT,R6       * GET USER'S JIT PAGE #
         SLS,R8   9               * MAKE IT A WORD ADDRESS
         AI,R8    M:UC-J:JIT      * POINT TO THE M:UC ADDRESS
         LW,R9    M24             * GET DCB MASK
         CS,R8    IOQ6,R3         * WAS DCB THE M:UC ?
         BE       RASCU10         * YEP - COULD BE TEL/DEL TALKING
RASCU2   EQU      %               *
RASCU3   EQU      %               *
         LI,R15   0               * INITIALIZE DELETED CHAR COUNTER
         LH,R4    IOQ9,R3         * GET BYT CNT OR # OF CDW'S
         LW,R5    IOQ8,R3         * BA OF BUF OR FIRST CDW ADRS (DBL)
         BGZ      RASCU9          * NOT DATA CHAINED
         AND,R5   M24             * MASK DBL-WORD ADDRESS
         SLS,R10  1               * SHIFT TDV DBL-WORD ADRS
         SLS,R5   1               * SHIFT FIRST DBL-WORD ADDRS
RASCU4   EQU      %               *
         LW,R6    M24             * GET BA MASK
         AND,R6   0,R5            * GET FIRST BA FIELD FROM CDW
         INT,R9   1,R5            * GET BYTE CNT FIELD
         CW,R5    R10             * IS THIS THE TDV STOP POINT
         BNE      RASCU5          * NO - NOT YET
         SW,R9    R11             * YES - RBC MINUS CDW CNT=TRUE CNT
         BGZ      RASCU5          * CAREFULL....
         LI,R9    1               * DO AT LEAST ONE BYTE
RASCU5   EQU      %               *
         BAL,R13  RAS:EDIT        * ENTER EDITOR
RASCU6   EQU      %               *
         INT,R9   1,R5            * CHECK NEXT SET OF FLAGS
         BCR,8    RASCU7X           NO MORE DATA CHAINING
         AI,R5    2               * BUMP WA POINTER TO CDW'S
         BDR,R4   RASCU4          *
RASCU7X  EQU      %
         LI,R4    4               * SET COUNT BACK TO ORIGINAL
         STB,R4   RAS:DOL+1       * LEVEL
RASCU7   EQU      %               *
         INT,R12  IOQ8,R3         * TEST FOR DATA CHAINED
         BCS,8    RASCU75         * CANNOT CHANGE BYTE CNT
         LH,R12   IOQ9,R3         * GET USER'S REQUESTED BYTE COUNT
         SW,R12   R15             * SUBTRACT # OF DELETED CHARS
         BGZ      %+2             * OK
         LI,R12   1               * SEND ONE
         STH,R12  IOQ9,R3         * CORRECT COUNT FOR ARS CALCULATION
RASCU75  EQU      %               *
         LI,R12   1               * SET TYC = NORMAL END
RASCU8   EQU      %               *
         LI,R13   0               * NO MESSAGE TO GO OUT
         B        IOSCU           *
RASCU9   EQU      %               *
         SW,R4    R11             * REQCNT - RBC = TRUE COUNT OF I/O
         BGZ      %+2             * OKAY
         LI,R4    1               * AT LEAST ONE
         LW,R9    R4              * MOVE BYTE COUNT
         LW,R6    R5              * MOVE BA OF BUFFER
         LI,R13   RASCU7X           RETURN ADDRESS
         B        RAS:EDIT        * GO EDIT BUFFER
         PAGE
*
*        BREAK DETEXTED IN AIO STATUS FROM LAST I/O OPERATION
*
BREAK    EQU      %
         PUSH     6,R14           * SAVE IOQ'S REGISTERS
         LB,R5    RAS:CBP         * GET USER NUMBER
         LI,R6    E:CBK           * BREAK EVENT CODE
         MTB,-1   RAS:DOL+1
         BNEZ     %+2
         LI,R6    E:CEC             BREAK WITH INPUT
         BAL,R11  T:RUE           * REPORT THE EVENT
         PULL     6,R14           * RESTORE THE I/O REGISTERS
         LI,R15   0
         B        RASCU7          * EXIIT TO IOSCU
         PAGE
*F*
*F*      NAME:    RASCU10
*F*
*F*      PURPOSE:
*F*               TO CHECK IF DELTA IS READING THRU THE M:UC DCB
*F*
*F*      DESCRIPTION:
*F*               THE USER'S FLAGS ARE CHECKED TO SEE IF DIC IS SET
*F*               IF NOT WE RETURN TO EDIT THE BUFFER.
*F*
*F*               IF THEY ARE SET - WE SEE IF ONLY A NEW LINE WAS
*F*               TYPED AND IF SO PLACE A 'COC' TYPE NEW LINE INTO
*F*               THE USER'S BUFFER.
*F*
*F*               IF MORE THAN ONE CHAR WAS TYPED WE GO AHEAD AND
*F*               EXIT BACK TO IOSCU.
*F*
RASCU10  EQU      %               *
         BAL,R15  GETFLAGS        * GET USER'S FLAGS
         CI,R4    DIC             * IS DELTA IN CONTROL
         BAZ      RASCU3          * GO AHEAD AND EDIT THE STRING
         LH,R7    IOQ9,R3         * GET REQUESTED BYTE COUNT
         SW,R7    R11             * REQ BYT CNT - RBC = TRUE CNT
         BLEZ     RASCU3          * ERROR - EDIT THE STRING
         CI,R7    1               * WAS ONLY A NEW LINE TYPED
         BLE      RASCU3          * YES - EXIT GRACEFULLY
         AW,R7    IOQ8,R3         * ADD BUFFER BASE BYTE ADDRESS
         AI,R7    -1              * ADJUST
         BLEZ     RASCU3          * ERROR
         LI,R9    13              *
         STB,R9   0,R7            * PLANT NEW LINE THERE
         B        RASCU3          * AND EXIT NORMALLY BACKTO IOQ
         PAGE
*F*
*F*      NAME:    T:RESCNCT
*F*
*F*      PURPOSE:
*F*               TO CONNECT THE MC USER'S M:UC DCB TO THE
*F*               RAS DEVICE.
*F*
*F*      DESCRIPTION:
*F*               SCHED CALLS HERE (MAPPED) WITH THE INTENTION
*F*               OF SETTING UP THE M:UC DCB TO POINT TO THE RAS.
*F*
*F*               T:RESCNCT WILL MAKE THE M:UC DCB WORD 1 LOOK LIKE
*F*               IT IS SUPPOSED TO BE OPENED TO THE RAS STATION.
*F*               SO WHEN LOGON TALKS TO THE USER IT WILL BE
*F*               READING/WRITING TO THE RAS STATION.
*F*
T:RESCNCT EQU     %               *
         LI,R6    1               * INDEX TO PICK UP
         LB,R6    RAS:CBP,R6      * RESOURCE INDEX
         LH,R6    SH:RNM,R6       * GET NAME
         LI,R1    1               *
         STH,R1   R6              * SET UP
         STW,R6   M:UC,R1         * FOR OPENDEV TO FIND THIS
         LI,R6    0               * NOW RESET
         STH,R6   UH:DL,R4        * DO LIST TABLE ENTRY
         LI,R1    1               * NOW RESET
         STH,R6   RAS:CBP,R1      * BRK SIGNAL/NEW LINE REQUIRED
         STH,R6   RAS:DOL+2,R1    * CLEAR SENT TO DATE BYTE COUNT
         B        T:DLR1          * AND EXIT TO SCHED
         PAGE
*F*
*F*      NAME:    RASBRK
*F*
*F*      PURPOSE:
*F*               TO ISSUE THE BREAK/CONTROL-Y EVENTS TO T:RUE IN
*F*               SCHED.
*F*
*F*      DESCRIPTION:
*F*               THE ONLY WAY TO GET HERE IS VIA AN UNSOLICITED
*F*               INTERRUPT DETECTED BY 'IOINT' IN 'IOQ'.
*F*
*F*               IOINT WILL GET HERE BY BAL,11 VIA THE POST-PROCESS
*F*               HANDLER ADDRESS MINUS ONE.
*F*
*F*
*F*               NOTE THAT T:RUE WILL EXIT DIRECTLY BACK TO IOINT
*F*               VIA R11 AND IOINT WILL EXIT BACK TO THE POINT
*F*               OF INTERRUPT.
*F*
RASBRK   EQU      %               *
         LI,R6    E:CBK           * ASSUME BREAK TO BE SENT
         MTB,-1   RAS:DOL+1       * CHECK ASSUMPTION
         BNEZ     %+2             * CORRECT ASSUMPTION
         LI,R6    E:CEC           * CONTROL-Y EVENT
         LB,R5    RAS:CBP         * GET THE USER'S #
         BEZ      *R11            * NONE - SO EXIT THE INT
         B        T:RUE           * RETURN IS IN R11 - REPORT EVENT
         PAGE
*F*
*F*      NAME:    RESCNCT
*F*
*F*      PURPOSE:
*F*               TO SAVE THE RESOURCE INDEX PASSED FROM KEYN TO
*F*               T:OV TO SCHED TO HERE.
*F*
*F*      DESCRIPTION:
*F*               SCHED HAS CALLED WITH THE RESOURCE INDEX IN BYTE
*F*               ZERO OF R10. WE WILL SAVE IT IN OUR TABLES AND
*F*               PLACE A DO-LIST ENTRY ADDRESS IN THE UH:DL
*F*               SLOT ASSIGNED TO THE RAS USER SO THAT T:RESCNCT
*F*               WILL BE CALLED PRIOR TO 'LOGON' STARTUP.
*F*
*F*               NOTE THAT THIS ROUTINE WILL BE RUNNING MAPPED
*F*               WHEN IT IS ACTIVATED.
*F*
RESCNCT  EQU      %               *
         LB,R1    R10             * GRAB INDEX
         STH,R1   RAS:CBP         * REMEMBER RESOURCE #
         LI,R1    DA(RAS:DOL)     * NOW
         STH,R1   UH:DL,R4        * STORE DOLIST ENTRY AWAY
         B        0,R2            * RETURN TO SCHED....
         PAGE
*F*
*F*      NAME:
*F*               RAS:ERR
*F*
*F*      PURPOSE:
*F*               TO ABORT THE USER CURRENTLY CONNECTED TO THE MC..
*F*
*F*      DESCRIPTION:
*F*               AN SIO FAILURE/DEVICE TIMEOUT HAS OCCURED-WE WILL
*F*               ISSUE THE ABORT CALL TO T:RUE AND STOP THE I/O
*F*               IN PROGRESS.
*F*
RAS:ERR  EQU      %               *
         LI,R6    E:ABRT          * YES - NEED TO DUMP USER OFF
         LB,R5    RAS:CBP         * GET THE USER'S NUMBER
         PUSH     6,R14           * T:RUE BLOWS A BUNCH OF REGISTERS
         BAL,R11  T:RUE           * REPORT THE EVENT
         PULL     6,R14           * RESTORE THE REGS
         LI,R12   8               * SETUP ERROR TYC/NO MORE I/O FLAGS
         LB,R13   DCT3,R1           CLEAR THE TIMEOUT BIT
         AND,R13  NB31TO0+5         BEFORE RETURNING
         STB,R13  DCT3,R1           TO IOSCU
         B        RASCU8          * RETURN TO IOSCU
*
*
*
*
         PAGE
*F*
*F*      NAME:    RAS:PRE
*F*
*F*      PURPOSE:
*F*
*F*      EDIT OUTGOING BUFFER
*F*
*F*      DESCRIPTION:
*F*      REGISTER ASSIGNMENTS:
*F*
*F*      R1 -     DCT INDEX
*F*      R2 -     CIT INDEX
*F*      R3 -     IOQ INDEX
*F*      R5 -     COUNT OF BLANKS TRAILING MSG
*F*      R6 -     BA OF BUFFER BASE
*F*      R7 -     BA OF CURRENT CHARACTER
*F*      R8 -     CURRENT CHARACTER
*F*      R9 -     LINK TO CALLER
*F*      R10-     .NE. ZERO SAYS USER SENT NEW LINE IN HIS BUFFER
*F*      R11-     SET WHEN TRAILING BLANKS PASSED IN BUFFER
*F*
*F*      WRITE I/O COMPLETION WILL CHECK TO SEE IF A NEW LINE SHOULD BE
*F*      BE SENT AND WILL SEND IT AS A FOLLOW ON IF NECESSARY.
*F*
RAS:PRE  EQU      %               *
         LH,R4    IOQ9,R3         * BYTE CNT OR # OF CDWS
         LW,R6    IOQ8,R3         * BA OF BUFFER OR FIRST CDW
         BLZ      CHAINED         * GO FIGURE OUT BYTE COUNT
         LI,R11   0               * CLEAR TRAILING BLANK FLAG REGISTER
         LW,R7    R6              * COPY BA OF BUFFER TO R7
         AW,R7    R4              * ADD BYTE COUNT
         AI,R7    -1              *
         LI,R5    0               * BLANK COUNTER
RAS:PRE1 EQU      %               *
         LB,R8    0,R7            * GET NEXT CHARACTER FROM STRING
         BEZ      RAS:PRE6        * SUPPRESS ZEROES WITH BLANKS
RAS:PRE15 EQU     %               *
         CI,R11   0               * HAVE WE PASSED TRAILING BLANKS
         BNE      RAS:PRE3        * YES - GO ON
         CI,R8    ' '             * IS CURRENT CHAR BLANK
         BE       RAS:PRE2        * YUP-KEEP COUNTING TRAILING BLANKS
         AI,R11   1               * NOPE - BUMP FLAG PAST END OF BLANKS
         B        RAS:PRE3        * AND JUMP
RAS:PRE2 EQU      %               *
         AI,R5    1               * BUMP COUNT OF TRAILING BLANKS
RAS:PRE3 EQU      %               *
         CI,R8    13              * IS A COC TYPE NEW LINE
         BNE      RAS:PRE35       * NOPE-GO ON
         LI,R8    X'15'           * YEP - CHANGE TO MC TYPE
         STB,R8   0,R7            * PLANT BACK IN THE BUFFER
RAS:PRE35 EQU     %               *
         AI,R7    -1              * KEEP BACKING UP
         CW,R7    R6              * DONT PASS END OF BUFFER
         BG       RAS:PRE1        * KEEP GOING
RAS:PRE4 EQU      %               *
         SW,R4    R5              * SUBTRACT TRAILING BLANK COUNT
         BGZ      %+2             * COUNT IS OKAY
         LI,R4    1               * WELL - SEND AT LEAST ONE OF EM
         STH,R4   IOQ9,R3         * REPLACE THE COUNT
RAS:PRE5 EQU      %               *
         LI,R6    1               * INDEX TO GET
         LH,R8    RAS:DOL+2,R6    * CURRENT CARRAIGE POSITION
         AW,R4    R8              * ADD IN CURRENT WRITE COUNT
         STH,R4   RAS:DOL+2,R6    * AND UPDATE CARRAIGE POSITION
         B        *R9             * RETURN TO CALLER
RAS:PRE6 EQU      %               *
         LI,R8    ' '             * REMOVE ZEROES
         STB,R8   0,R7            * IN ALL OUTPUT LINES
         B        RAS:PRE15       * ENTER EDITOR AGAIN
         PAGE
*
*        CURRENT WRITE OPERATION IS DATA CHAINED
*
CHAINED  EQU      %               *
         SLS,R6   1               * CONVERT TO WA FORMAT
         LI,R7    0               * CLEAR ACCUMULATOR
CHAINED0 EQU      %               *
         INT,R5   1,R6            * GET BYTE COUNT FROM CDW WORD 1
         AW,R7    R5              * ADD IN W/TOTAL
         BDR,R4   CHAINED0        * FINISH UP
         LW,R4    R7              * MOVE TO MERGE
         B        RAS:PRE5        * MOVE TO COMMON STORE ROUTINE
         PAGE
*F*
*F*      NAME:    RAS:SET
*F*
*F*      PURPOSE:
*F*               TO SEND THE BREAK WATCH SIGNAL TO THE
*F*               RAS DEVICE.
*F*
*F*      DESCRIPTION:
*F*               THE SLOT IN THE RAS TABLES IS SET TO ONE
*F*               EVERY TIME WE SEND THE BREAK WATCH SIGNAL - AND
*F*               IS SET BACK TO ZERO EVERY TIME THE USER LOGS
*F*               OFF THE SYSTEM.
*F*
*F*               SO - WHENEVER THE SLOT IS ZERO WE SEND THE BREAK
*F*               WATCH SIGNAL -
*F*
RAS:SET  EQU       %              *
         LI,R7    2               * INDEX
         MTB,0    RAS:CBP,R7      * TO TEST IF WE SENT SIGNAL YET
         BNEZ     *R8             * YEP
         LI,R0    DA(TYB)         *
         LH,R6    DCT1,R1         * GET THE DEVICE ADDRESS
         SIO,R0   0,R6            * ARM THE BREAK HIT THINGAMAJIG
         MTB,1    RAS:CBP,R7      * SET SIGNAL SENT TO STATION
         B        *R8             * AND EXIT
         PAGE
*F*
*F*      NAME:    RAS:EDIT
*F*
*F*      PURPOSE:
*F*
*F*      EDIT INCOMING (READ) BUFFER TO HONOR DELETED CHARACTERS,
*F*      RETRY READ (ON EOM) ETC...
*F*
*F*      DESCRIPTION:
*F*
*F*      REGISTER ASSIGNMENTS;
*F*
*F*      R1  -    DCT INDEX
*F*      R2  -    CIT INDEX
*F*      R3  -    IOQ INDEX
*F*      R4  -    # COMMAND DBL WORDS
*F*      R5  -    WA OF CURRENT CDW
*F*      R6  -    CURRENT CHAR BA RETURNED TO THE RAS USER
*F*      R7  -    CURRENT CHAR BA WE ARE EDITING
*F*      R8  -    CURRENT CHAR
*F*      R9 -     SCRATCH REGISTER
*F*      R10 -    TDV CDW POINTER
*F*      R11 -    RBC FROM TDV DBL-WORD
*F*      R12 -    BUFFER BASE BOUNDARY BA
*F*      R13 -    RETURN LINK ADDRESS
*F*      R14 -    DEVICE ACTIVITY COUNTER IN USE BY IOQ
*F*      R15 -    DELETED CHARACTER COUNTER
*F*
RAS:EDIT EQU      %               * BASE BUFFER BA POINT
         LW,R12   R6              * HOLD BUF BA IN R12
         LW,R7    Y04             * GET MBS REGISTER SET UP
         MBS,R6   0               * GET FIRST 4CHAR OF BUFFER
         CW,R0    XEOD            * IS IT A BANG EOD CARD/CHAR STRING
         BNE      RAS:EDIT0       * NOPE
         LI,R12   6               * SET TYC = EOD
         B        RASCU8          * MERGE W/COMMON EXIT
RAS:EDIT0 EQU     %               *
         LW,R6    R12             * RESTORE BUF BA BASE AGAIN
         LW,R7    R6              * COPY DEST BA TO R7
RAS:EDIT1 EQU     %               *
         LB,R8    0,R7            * GET NEXT EDITING CHARACTER
         CI,R8    '@'             * IS A DELETED CHAR
         BE       RAS:EDIT3       * YES - DONT MOVE IT
         STB,R8   0,R6            * OKAY - MOVE IT
         AD,R6    DOUBLEONE       * BUMP BOTH POINTERS ON A MOVE
RAS:EDIT2 EQU     %               *
         CI,R8    8               * IS CHAR AN EOM
         BE       RASRTRY         * YES - RETRY ENTIRE LINE
         BDR,R9   RAS:EDIT1       * FINISH UP
         B        *R13            * RETURN TO FRONT END
RAS:EDIT3 EQU     %               *
         AI,R15   1               * BUMP COUNT OF DELETED CHARACTERS
         AI,R6    -1              * RETREAT THE BUFFER OUTPUT POINTR
         CW,R6    R12             * HAVE WE PASSED BUFFER BOUNDARY
         BGE      %+2             * NOT YET
         LW,R6    R12             * INSURE WE DO NOT PASS IT
         AI,R7    1               * ADVANCE INPUT STRING POINTER
         B        RAS:EDIT1       * AND KEEP EDITING
         PAGE
*F*
*F*      NAME:    RASRTRY
*F*
*F*      PURPOSE:
*F*               TO INITIATE RETRY AND TO FLAG A NEW LINE S/B
*F*               SENT BEFORE THE NEXT I/O.
*F*
*F*      DESCRIPTION:
*F*               WE COME HERE TO FLAG RETRY BACK TO IOQ - RESETTING
*F*               THE NEW LINE NECESSITY TABLE SLOT TO FORCE OUT
*F*               A NEW LINE SEQUENCE NEXT TIME AROUND.
*F*
RASRTRY  EQU      %               *
         LI,R12   X'C008'         * LOAD ERROR CODES / TYC
         LB,R13   IOQ11,R3
         BNE      RASCU8
         LI,R13   MSG2
         B        IOSCU
         PAGE
*F*
*F*      NAME:    TELCHK
*F*
*F*      PURPOSE:
*F*
*F*               TO EXAMINE FOR THE NECESSITY OF SENDING THE
*F*               NEW LINE/PROMPT CHAR PRIOR TO DOING A READ.
*F*
*F*      DESCRIPTION:
*F*               WE WILL LOOK AT THE USER FLAGS TO SEE IF IT
*F*               WILL BE NECESSARY TO SEND THE PROMPT SEQUENCE.
*F*
*F*               CERTAIN REGISTERS ARE NOW IN USE BY COMLIST - REGS
*F*               THAT MUST BE PRESERVED;
*F*
*F*      R1  -    DCT INDEX
*F*      R2  -    CIT INDEX
*F*      R3  -    IOQ INDEX
*F*      R4  -    CAN BE USED HERE
*F*      R5  -    IN USE BY COMLIST
*F*      R6  -    IN USE BY COMLIST
*F*      R7  -    IN USE BY COMLIST
*F*      R8/R9    CONTAINS CURRENT COMMAND DOUBLE WORD COMLIST HAS
*F*      R10 -    POINTS TO DOT TABLE FOR COMLIST'S USEAGE
*F*      R11 -    USED HERE FOR NL/PROMPT POINTER INSERTION
*F*
*F*               WE GET HERE FROM HANDLERS (COMLIST) AND WE
*F*               INSERT A CDW CONTAINING A NEW LINE/PROMPT CHAR
*F*               WRITE PRIOR TO THE USER'S READ ***ONLY IF TEL
*F*               IS NOT IN CONTROL***
*F*
*F*               IF TIC WE LET THE READ GO THRU.
*F*
TELCHK   EQU      %               *
         LI,R11   BA(RAS:DOL+2)+1 * LOAD NL/PROMPT BA
         BAL,R12  RAS:CNT         * FETCH CCP
         CI,R15   20              * SHOULD THE READ HAVE A NEW LINE
         BLE      TELCHK0         * NOPE
         AI,R11   -1              * YES - POINT TO BYTE ADDRS OF N/L
         AI,R9    1               * INCREASE BYTE COUNT
         B        NLCHK1          * MERGE TO CLEAR CCP SLOT
TELCHK0  EQU      %               *
         BAL,R15  GETFLAGS        * GET USERS FLAGS
         CI,R4    DIC             * IS DELTA IN CONTROL
         BANZ     TELCHK1         * YUP-GIVE DELTA USER A PROMPT
         CI,R4    TIC             * IS TEL IN CONTROL
         BANZ     TELCHK2         * YEP - DELETE CDW AND GO ON
TELCHK1  EQU      %
         LI,R4    0               * CLEAR FLAG
         AND,R9   NBYT2           * CLEAR HANDLER FUNCTION FLAG
         OR,R8    R11             * AND INSERT BA OF NEW LOCATION
         B        USECOM          * REJOIN HANDLERS
TELCHK2  EQU      %               *
         LI,R4    0               * CLEAR FLAGS
         B        DELCOM          * DEELETE PROMPT CHAR CDW
         PAGE
*F*
*F*      NAME:    NLCHK
*F*
*F*      PURPOSE: TO CHECK TO SEE IF WE SHOULD SEND A NEW LINE OUT
*F*               IN FRONT OF THE WRITE CURRENTLY BEING BUILT.
*F*
*F*      DESCRIPTION:
*F*               IF THE CURRENT CARRAIGE POSITION IS > 40 WE WILL
*F*               SEND A NEW LINE OUT PRIOR TO WRITING THE BUFFER
*F*
NLCHK    EQU      %
         LI,R11   BA(Y15)         * LOAD BA OF NEW LINE CELL
         BAL,R12  RAS:CNT         * GET CURRENT CARRAIGE POSITION
         CI,R15   40              * AT MAX LINE WIDTH
         BL       TELCHK2         * NO-DELETE CDW AND WRITE BUFER OUT
NLCHK1   EQU      %               * COME HERE TO CLEAR CCP
         LI,R15   0               * MAX-LETS CLEAR
         STH,R15  RAS:DOL+2,R4    * THE CARRAIGE POSITION POINTER
         B        TELCHK1         * AND SEND THE NEW LINE OUT FIRST...
*
*
         PAGE
*
*        GET CURRENT CARRAIGE POSITION COUNTER
*
RAS:CNT  EQU      %
         LI,R4    1               * INDEX TO SLOT
         LH,R15   RAS:DOL+2,R4    * GET CCP
         B        *R12            * RETURN
         PAGE
*F*
*F*      NAME:    GETFLAGS
*F*
*F*      PURPOSE:
*F*               TO GET THE RAS USER'S FLAGS FROM UH:FLG
*F*
*F*      DESCRIPTION:
*F*               BAL HERE AND GETFLAGS WILL PICK THEM UP.
*F*
GETFLAGS EQU      %               *
         LB,R4    RAS:CBP         * USER NUMBER
         LH,R4    UH:FLG,R4       * GET THE FLAGS
         B        *R15            * AND RETURN
         END

