         DEF      2780IO:           FOR XDELTA SYMBOL
2780IO:  EQU      %
*
*
*M*      2780IO   IBM 2780 RBT HANDLER, DATA MANAGER, AND LINE MANAGER
*
*
*P*      NAME:    2780IO
*P*
*P*      PURPOSE: HANDLER, LINE MANAGER AND BLOCKER-DEBLOCKER FOR
*P*               7605'S TO WHICH 2780 RBTS ARE CONNECTED
*P*
*P*      DESCRIPTION:
*P*               2780IO CONSISTS OF FIVE BASIC PARTS AS DESCRIBED
*P*               BELOW.  IT MUST BE COMBINED WITH RBBAT, RBSSS, AND
*P*               BSCIO TO PROVIDE COMPLETE 2780 SUPPORT.
*P*
*P*               1)  THE LINE HANDLER:  THIS PART IS A MORE OR LESS
*P*               COMMON CP-V DEVICE HANDLER, ACCEPTING FUNCTION CODES
*P*               RETURNING TYC'S AND FOLLOWING THE RULES FOR DEVICE
*P*               HANDLERS.  IT IS CALLED BY THE REST OF 2780IO VIA
*P*               NEWQ, AND HAS NO OTHER REAL CONNECTION WITH THE
*P*               OTHER PARTS.  IT MANAGES THE LINE PROTOCOL (BISYNC),
*P*               AND CRC'S INPUT BLOCKS.
*P*
*P*               2)  THE BLOCK PARSER:  THIS PART IS CALLED
*P*                   EITHER BY THE COMMON PARSE ROUTINE AS A
*P*                   RESULT OF A READ BEING ISSUED BY AN
*P*                   INPUT SYMBIONT, OR BY THE LINE MANAGER AT
*P*                   THE END OF EACH INPUT I/O. IF INPUT HAS BEEN
*P*                   RECIEVED FROM THE LINE THE PARSER DE-BLOCKS
*P*                   EACH RECORD IN THE BLOCK, EXPANDS IT TO 80
*P*                   BYTES IF IT ENDS WITH AN EM CHARACTER,
*P*                   AND GIVES IT TO THE APPROPRIATE INPUT
*P*                   SYMBIONT BY FAKING END-ACTION.  IF NO READ
*P*                   IS PENDING FOR THAT SYMBIONT THE PARSER
*P*                   EXITS KNOWING IT WILL BE CALLED AGAIN WHEN
*P*                   A READ IS READY.
*P*
*P*               3) THE BLOCK BUILDER:  THIS PART IS CALLED EITHER
*P*               BY THE COMMON BUILD ROUTINE, THE LINE MANAGER AFTER
*P*               EACH OUTPUT I/O, OR BY THE LINE MANAGER WHEN AN
*P*               OUTPUT BLOCK IS NEEDED AND NONE IS READY.  IT TAKES
*P*               RECORDS FROM THE OUTPUT SYMBIONT, ADDS ENDING, LEADING
*P*               AND DEVICE SELECT SEQUENCES, CRC'S THE RECORDS AND
*P*               BLOCKS THEM FOR TRANSMISSION.  THE BLOCKS BUILT
*P*               CONTAIN EITHER ONE RECORD OR 400 BYTES DEPENDING ON
*P*               THE SPECIFICATION OF MRB OR SRB IN SUPER FOR THE
*P*               WORKSTATION.  EACH BLOCK ENDS WITH ETB EXCEPT THE
*P*               LAST WHICH ENDS WITH ETX.
*P*
*P*               4)  THE LINE MANAGER:  THIS PART OF 2780IO IS
*P*                   A SORT OF SUPER SYMBIONT FORR THE LINE.
*P*                   AFTER BEING STARTED BY RBBAT IT GOES TO
*P*                   NEWQ, SPECIFYING ITSELF AS THE END-ACTION
*P*                   IT IS THUS INTERRUPT DRIVEN BY ITS OWN I/O.
*P*                   THE BASIC TASK OF THE LINE MANAGER IS TO
*P*                   PASS INPUT BLOCKS TO THE BLOCK PARSER AND
*P*                   TRANSMIT OUTPUT BLOCKS FROM THE BLOCK
*P*                   PARSER TO THE HANDLER TO BE OUTPUT.  THIS
*P*                   PART ALSO HANDLES INPUT AND OUTPUT END-OF-
*P*                   FILE'S AND POLLING ON THE LINE.  IT STARTS
*P*                   THE INPUT SYMBIONT WHEN ITS POLL HAS BEEN
*P*                   RECIEVED.  WHEN ALINE I/O HAS BEEN STARTED,
*P*                   IT CALLS EITHER THE PARSER OR THE BUILDER
*P*                   WHICHEVER IS APPROPRIATE.
*P*
*P*               5)  THE SYMBIONT MANAGER:  THIS PART IS CALLED
*P*               BY RBSS OFF THE FIVE SECOND CLOCK.  IF THE LINE
*P*               IS IDLE IT CHECKS WHETHER OUTPUT IS READY. IF
*P*               NONE IS IT STARTS UP A POLL FOR INPUT.  FOR
*P*               OUTPUT IT STARTS AN APPROPRIATE SYMBIONT AND
*P*               INITIATES A POLL TO OUTPUT.
*P*
*P*               2780IO IS THE HANDLER FOR ALL LINES IN A SYSTEM WHICH
*P*               HAS BOTH IRBT AND 2780.  FROM THE INITIAL LINE BID IT
*P*               DETERMINES WHETHER THE LINE IS 2780 (ENQ) OR IRBT (SOH
*P*               ENQ) AND IF IT IS IRBT, CHANGES THE HANDLER ADDRESSES
*P*               TO HASPIO AND ENTERS HASPIO TO CONTINUE THE LOGON PROCESS
*P*
*P*      REFERENCE:
*P*               THE SYMBIONT AND REMOTE PROCESSING TABLES ARE
*P*               DOCUMENTED IN THE DATA BASE TECH. MANUAL.  THE
*P*               MODULES RBSSS, BSCIO AND RBBATM ARE DEEPLY
*P*               INVOLVED IN 2780 PROCESSING.
*P*
*
*
*********************************************************
*     THIS ASSEMBLY CONTAINS THE BASIC PARTS OF THE CPV *
*2780 SUPPORT:  1) THE HANDLER, 2) THE BLOCK BUILDER,   *
*3) THE BLOCK PARSER, 4) THE LINE MANAGER, AND 5) THE   *
*SYMBIONT MANAGER.  IT MUST BE COMBINED WITH RBSSS AND  *
*BSCIO IN THE SYSTEM TO SUPPORT 2780'S -- SMK           *
*********************************************************
         SYSTEM   SIG7P
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4                 THE HANDLER PART USES THE
R5       EQU      5                 STANDARD HANDLER REG SETUP
R6       EQU      6                 WITH THE ADDITION OF R13=
R7       EQU      7                 RB:FLAGS  -- IN MOST OF THE
BLNK     EQU      X'40'
R8       EQU      8                 OTHER PARTS R7=DCTX AND
R9       EQU      9                 R6=CXT ADDR (RB:BUF) OFTEN
R10      EQU      10                R4 IS A SYMB INDEX AND R5
R11      EQU      11                AN IOQX
R12      EQU      12
R13      EQU      13
R14      EQU      14
R15      EQU      15
********
*
*
*
         DEF      2780IO            HANDLER FRONTEND ENTRY POINT
         DEF      2780CU            HANDLER BACKEND ENTRY POINT
         DEF      2780BIT           RB:FLAG BIT THAT SAYS LINE IS 2780
         DEF      27P               BEGIN BLOCK PARSING ENTRY POINT
         DEF      27P2              CONTINUE BLOCK PARSING ENTRY POINT
         DEF      27PEF             END-OF-FILE FOUND PARSING ENTRY POINT
         DEF      27B               BEGIN BLOCK BUILDING ENTRY POINT
         DEF      27BG              CONTINUE BLOCK BUILDING ENTRY POINT
         DEF      27CTL             LINE CONTROL ENTRY POINT
         DEF      27HU              LINE DISCONNECT ENTRY POINT
         DEF      27WRT             FORCE WRITE WORKED ENTRY POINT
         DEF      27DIO1            FORCE WRITE FAILED ENTRY POINT
         DEF      27SSS             5 SEC. CLOCK ROUTINE CALLED BY RBSSS
*
*
         REF      Y8                RB:FLAG BIT - BPBIT
         REF      Y4                RB:FLAG BIT - IGBIT
         REF      Y2                RB:FLAG BIT - MORBIT
         REF      Y1                RB:FLAG BIT - HUBIT
         REF      Y08               RB:FLAG BIT - PUNBIT
         REF      Y04               RB:FLAG BIT - DCBIT
         REF      Y02               RB:FLAG BIT - HASPBIT
         REF      Y01               RB:FLAG BIT - SLVBIT
         REF      Y008              RB:FLAG BIT - ALBIT
         REF      Y004              RB:FLAG BIT - XP1BIT
         REF      Y002              RB:FLAG BIT - 2780BIT
         REF      Y001              RB:FLAG BIT - IBMBIT
         REF      Y0008             RB:FLAG BIT - DIALBIT
*
         REF      Y07               EOF TYC FOR INSYM
         REF      NB31TO0           MASKS
         REF      M31               MASK
         REF      M24               MASK
         REF      M6                MASK
         REF      M4                MASK
*
         REF      DCT8              OUTPUT: HASPIO STORED HERE WHEN IRBT
*,*                                 LINE IS DETECTED.
         REF      DCT9              OUTPUT: HASPCU STORED HERE WHEN IRBT
*,*                                 LINE IS DETECTED
*
         REF      IOQ4              I/O: CALLING FUNCTION CODE USED TO
*,*                                 DETERMINE CODE PATH
         REF      IOQ5              I/O: CURRENT FUNCTION CODE USED TO
*,*                                 DETERMINE CODE PATH
         REF      IOQ8              I/O: BUFFER BYTE ADDRESS CHANGED FOR
*,*                                 LOGON SEQUENCE
         REF      IOQ9              I/O: BUFFER BYTE COUNT CHANGED FOR
*,*                                 LOGON SEQUENCE
         REF      IOQ10             INPUT: RETRIES REQUESTED USED TO
*,*                                 DETECT WHETHER THIS IS A RETRY
         REF      IOQ11             INPUT: RETRIES REMAINING USED TO
*,*                                 DETECT WHETHER THIS IS A RETRY
*
         REF      RB:BUF            INPUT: CONTEXT ADDRESS USED TO TELL
*,*                                 WHETHER THE LINE IS LOGGED ON
         REF      RB:FLAG           I/O: REMOTE PROCESSING CONTROL FLAG
*,*                                 BITS USED TO DECIDE WHAT TO DO
         REF      RBB:CPZ           INPUT: MAXIMUM LENGTH OF PUNCH RECORDS
         REF      RBB:LPZ           INPUT: MAXIMUM LENGTH OF PRINT RECORDS
         REF      RBH:ACK           I/O: SPECIAL SHORT MESSAGE BUFFER
         REF      RBB:HFE           INPUT: HEAD OF SYMBIONTS FOR THIS LINE
         REF      RBB:HOU           I/O: CURRENT OUTPUT SYMBIONT FOR THIS
*,*                                 LINE
         REF      RBB:HIN           I/O: CURRENT INPUT SYMBIONT FOR THIS
*,*                                 LINE
*
         REF      SSIG              I/O: SYMBIONT SIGNAL USED TO TELL WHEN
*,*                                 SYMBIONTS ARE RUNNING AND START THEM
         REF      STB:LNK           INPUT: SYMBIONT RP LINK USED TO RUN
*,*                                 RBB:HFE CHAIN
         REF      STB:Q             INPUT: HOLDS IOQX OF SYMBIONT QUEUE CALL
         REF      STB:TYP           INPUT: USED TO TELL PRINTERS FROM PUNCHES
         REF      STH:FLG           INPUT: SYMBIONT RP FLAGS USED TO TELL
*,*                                 WHICH OUTPUT SYMBIONTS ARE LOCKED
*,*                                 OR HAVE OUTPUT READY
*
         REF      BLANK             INPUT: WORD OF TEXT BLANKS USED TO MBS
*,*                                 BLANK PAD INPUT RECORDS WITH EM'S
         REF      TSTACK            TO PUSH AND PULL
         REF      HUP               RBBAT GFC FOR HUNG UP LINE
         REF      GMBSIZ            WORD SIZE OF AN MPOOL USED WHEN READING
*,*                                 LOGON RECORD INTO ONE
*
         REF      BSCAKM            INPUT: CANNED ACK0 MESSAGE
         REF      BSCNAKM           INPUT: CANNED NAK MESSAGE
         REF      4SYNC             INPUT: FOUR SYNC'S FOR MESSAGE LEADER
*
         SREF     HASPIO            STORED INTO DCT8 WHEN IRBT LINE IS
*,*                                 DETECTED
         SREF     HASPCU            STORED INTO DCT9 WHEN IRBT LINE IS
*,*                                 DETECTED
*
         REF      NXT%DEV           CALLED: TO EXIT THE 5SEC CLOCK ROUTINE
         REF      RB%TDV            CALLED: TO TEST FOR HANG UPS AND DIAL UPS
         REF      RB%CU             CALLED: TO PERFORM COMMON HANDLER BACKEND
*,*                                 TASKS
         REF      RB%PREX           CALLED: TO EXIT HANDLER FRONTEND
         REF      BSC%PX            CALLED: TO EXIT HANDLER BACKEND FOR THE
*,*                                 FINAL TIME ON AN I/O WITH NORMAL TYC
         REF      BSC%PX1           CALLED: TO EXIT HANDLER BACKEND FOR THE
*,*                                 FINAL TIME ON AN I/O WITH ACK TYC
         REF      BSC%FL            CALLED: TO EXIT HANDLER BACKEND FOLLOWING
*,*                                 ON TO NEXT FUNCTION CODE (DCT17)
         REF      BSC%PRE           CALLED: TO PERFORM COMMON HANDLER FRONTEND
*,*                                 TASKS
         REF      BSC%GL            CALLED: TO GET (-) BYTE COUNT AND FIRST
*,*                                 CHARACTER OF INPUT MESSAGE
         REF      BSC%LGN           CALLED: TO REPORT LOGON REC RCVD TO RBBAT
         REF      BSC%GN            CALLED: TO REPORT TERM HANG UP TO RBBAT
         REF      NEW%FLO           CALLED: TO SET A NEW F.C.PATH AND FOLLOWON
*,*                                 TO IT.
         REF      RPT%ORG           USED AS EXIT FROM LOG%ERR TO REPEAT
*,*                                 CALLING FUNCTION CODE
         REF      BSCSPC1           CALLED: THROUGH COMLIST TO BUILD CMND
*,*                                 DW TO READ INTO RBH:ACK
*
         REF      BSC%BO            CALLED: TO EXIT BLOCK BUILDER
         REF      BSC%PO            CALLED: TO EXIT BLOCK PARSER
         REF      BSC%HO            CALLED: TO EXIT THE HANG UP ROUTINE
         REF      BSC%GO            CALLED: TO EXIT THE LINE CONTROL ROUTINE
         REF      BSC%FB            CALLED: TO FREE A LINE BUFFER
         REF      BSC%GB            CALLED: TO GET A LINE BUFFER
         REF      BSC%BLD           CALLED: TO START BUILDING AGAIN AFTER
*,*                                 A LINE IO HAS BEEN QUEUED
         REF      BSC%PRS           CALLED: TO START PARSING AGAIN AFTER A
*,*                                 LINE I/O HAS BEEN QUEUED
         REF      BSCDIO            CALLED: TO DO LINE I/O
         REF      FORCWR            CALLED: TO TRY TO FORCE A WRITE BUFFER
*,*                                 FULL WHEN THE LINE NEEDS ONE
         REF      BSC%DSC           CALLED: TO CHECK WHETHER THE WSN HAS
*,*                                 LOGGED OFF AND DISCONNECT THE LINE IF
*,*                                 HIS OUTPUT IS DONE
         REF      BSC%BO1           CALLED: TO EXIT BLOCK BUILDER
         REF      BSC%EOB           CALLED: WHEN THE END OF AN INPUT BLOCK
*,*                                 IS FOUND
         REF      BSC%BC            CALLED: TO CLOSE OFF AN OUTPUT BLOCK
         REF      BSC%PEA           CALLED: TO GIVE PSEUDO END ACTION TO AN
*,*                                 INPUT SYMBIONT
         REF      BSC%HEA           CALLED: TO GIVE A SYMBIONT PSEUDO
*,*                                 ENDACTION WITH HUNG UP TYC
         REF      BSC%FEC           CALLED: TO TEST FOR LINE ERRORS IF
*,*                                 TERMINAL IS ON FECP
         REF      ENDAC             CALLED: TO GIVE PSEUDO END ACTION WITH
*,*                                 NORMAL TYC
         REF      ENDAC1            CALLED: TO GIVE PSEUDO END ACTION WITH
*,*                                 EOF, BACKUP OR HUNG UP TYC
*
         REF      UNKN%RD1          CALLED: TO REPORT REMOTE PROCESSING ERROR
*,*                                 BAD INPUT FIRST CHARACTER
         REF      UNKN%RD3          CALLED: TO REPORT REMOTE PROCESSING ERROR
*,*                                 BAD INPUT ENDING CHARACTER
         REF      UNKN%RD4          CALLED: TO REPORT REMOTE PROCESSING ERROR
*,*                                 UNKNOWN RESPONSE READING FOR ACK
         REF      ENQ%PRB           CALLED: TO REPORT REMOTE PROCESSING ERROR
*,*                                 ENQ RECIEVED AT WRONG TIME OR ACK
*,*                                 NOT HEARD BY HIM
         REF      ENQ%NOT           CALLED: TO REPORT REMOTE PROCESSING ERROR
*,*                                 ENQ LINE BID NOT RECIEVED AT LOGON
         REF      BD%CRC            CALLED: TO REPORT REMOTE PROCESSING ERROR
*,*                                 BAD CRC ON INPUT BLOCK
         REF      BD%BCB            CALLED: TO REPORT REMOTE PROCESSING ERROR
*,*                                 EITHER INPUT ABORT OR ATTEMPT BY IRBT
*,*                                 TO LOGON TO 2780 ONLY SYSTEM
         REF      HE%NAKD           CALLED: TO REPORT REMOTE PROCESSING ERROR
*,*                                 NAK RECIEVED
         REF      TO%OUT            CALLED: TO REPORT REMOTE PROCESSING ERROR
*,*                                 TIME OUT
         REF      LGN%ACK           CALLED: TO REPORT REMOTE PROCESSING ERROR
*,*                                 NON-EOT RESPONSE TO EOF BLOCK
         REF      LOG%ERR           CALLED: TO REPORT REMOTE PROCESSING ERROR
*,*                                 NO RESPONSE TO OUTPUT POL
*
         REF      E%DISC            USED AS EXIT ON INPUT ABORT -
*,*                                 ERROR MAXES LINE
         SREF     H%LGST            CALLED: TO ENTER HASPIO WHEN IRBT LOGON
*,*                                 IS DETECTED
         REF      RBSGCQ1           CALLED: TO REPORT HUP TO RBBAT
         REF      SAQNSERT          CALLED: TO START SYMBIONTS
*
         REF      CRC1              CALLED: TO CRC ONE CHARACTER AND STORE
*,*                                 IT IN AN OUTPUT BUFFER
         REF      CRCI              CALLED: TO CRC INPUT MESSAGES
         REF      CRCI3             CALLED: TO RETURN TO CRCI FROM SPECIAL
*,*                                 CHAR CHECKER ON NORMAL CHARS
         REF      CRCI4             CALLED: TO RETURN TO CRCI FROM SPECIAL
*,*                                 CHAR CHECKER ON SYNC (DONT CRC)
         REF      CRCX              CALLED: TO CRC OUTPUT MESSAGES
         REF      CRCO3             SINCE NO DLE CHECK IS DONE, THIS
*,*                                 IS SPECIFIED AS THE DLE CHECKER
*
*
*
**********************************************
*
*        FLAG WORD BIT MASKS
*
FRBIT    EQU      1
EMBIT    EQU      2
OBBIT    EQU      1
FINBIT   EQU      4
LIPBIT   EQU      8
SSSBIT   EQU      X'10'
FIABIT   EQU      X'20'
OADBIT   EQU      X'40'
XP2BIT   EQU      X'80'
CTRBIT   EQU      X'100'
ACTBIT   EQU      X'200'
CLKBIT   EQU      X'400'
HALBIT   EQU      X'800'
SYSBIT   EQU      X'1000'
LOFBIT   EQU      X'2000'
DISCBIT  EQU      X'4000'
DUPBIT   EQU      X'8000'
RBXBIT   EQU      X'10000'
OFFBIT   EQU      X'20000'
EDISBIT  EQU      X'40000'
DIALBIT  EQU      Y0008             BIT DEFINITIONS FOR RB:FLAG
IBMBIT,3780BIT EQU Y001             SEE DATA BASE TECH MANUAL
2780BIT  EQU      Y002
XP1BIT   EQU      Y004
ALBIT    EQU      Y008
SLVBIT   EQU      Y01
HASPBIT  EQU      Y02
DCBIT    EQU      Y04
PUNBIT   EQU      Y08
HUBIT    EQU      Y1
MORBIT   EQU      Y2
IGBIT    EQU      Y4
BPBIT    EQU      Y8
*
NMORBIT  EQU      NB31TO0+30        EVERYTHIN BUT MORBIT
NFINBIT  EQU      NB31TO0+3                       FINBIT
NBPBIT   EQU      M31                   "      "  BPBIT
*
SYNC     EQU      X'32'
SOH      EQU      X'01'
STX      EQU      X'02'
IRS      EQU      X'1E'             INTRA-RECORD SEPARATOR
IGS      EQU      X'1F'             SPACE COMPRESSION IDENTIFIER
ITB      EQU      X'1F'
ETB      EQU      X'26'
ETX      EQU      X'03'
ENQ      EQU      X'2D'
EOT      EQU      X'37'
NAK      EQU      X'3D'
DLE      EQU      X'10'             BSC-EBCDIC LINE CODES
ACK0     EQU      X'70'
ACK1     EQU      X'61'
WACK     EQU      X'6B'
RVI      EQU      X'7C'
EM       EQU      X'19'
BEL      EQU      X'2F'
ESC      EQU      X'27'
PAD      EQU      X'FF'
*********
PRESC    EQU      X'61'             PRINTER NORMAL SELECT
PUESC    EQU      X'F4'             PUNCH SELECT
PUTYP    EQU      5                 PUNCH DEV TYPE
BUFSZ    EQU      404               BUF SIZE IN BYTES
LOCBIT   EQU      X'10'             STREAM LOCKED
STPBIT   EQU      X'400'            DATA READY FOR THIS STREAM
*****************************************
*                                   CALLING FC'S
*
WRFCN    EQU      1                 WRITE
ENQFCN   EQU      2                 WAIT TO WRITE
RDFCN    EQU      3                 READ
WACKFCN  EQU      4                 WAIT TO READ
WEOFCN   EQU      5                 WRITE LAST BLK AND EOF
POL1FCN  EQU      6                 REQUEST TO OUTPUT
POL2FCN  EQU      7                 POL FOR INPUT
*
*                                   HANDLER TYC'S
*
NPTYC    EQU      1                 NORMAL (OR POL FAILED)
HUTYC    EQU      2                 HUNG UP
PRTYC    EQU      3                 POL RECIEVED
PATYC    EQU      4                 OUT REQ. ACCEPTED
LEOFTYC  EQU      5                 EOF RCVD
RCVRTYC  EQU      6                 OUTPUT ABORT DETECTED
EOFTYC   EQU      Y07               EOF TO INPUT SYMB
*****************************************
*                                   CONTEXT POINTERS****
FNSV     EQU      0
HPB      EQU      1                 HEAD PARSE BUFFS
HBB      EQU      2                 HEAD BUILD BUFFS
HRB      EQU      3                 HEAD READ BUFFS
HWB      EQU      4                 HEAD WRITE BUFFS
CPB      EQU      5                 CURRENT PARSE BUFF
CBB      EQU      6                 CURRENT BUILD BUFF
CRB      EQU      7                 CURRENT READ BUFF
CWB      EQU      8                 CURRENT WRITE BUFF
POP      EQU      9                 POINTER OF PARSE
POB      EQU      10                POINTER OF BUILD
PIP      EQU      11                PARSE IN PROGRESS
CBCB     EQU      12                *UNUSED IN 2780*
OCRCB    EQU      13                *UNUSED*
RBC      EQU      14                REMAINING BYTE COUNT (OUT)
CCRC     EQU      15                CUR CRC (OUT)
CURX     EQU      16                HOLDS O.S.UNTIL READY
BIP      EQU      17                BUILD IN PROGRESS
FBF      EQU      18                FORCE BUFFER FULL
CIP      EQU      19                CONTROL IN PROGRESS
FCSI     EQU      20                TEMP HOLD TO CVT VFC
CFC      EQU      21                CUR. FUNCTION CODE
BUT      EQU      22                *UNUSED*
BIN      EQU      23                *UNUSED*
CURF     EQU      24                # OF RECS IN CUR BLK
LTYC     EQU      25                LINE TYC
RST      EQU      26                *UNUSED*
SAB      EQU      27                TURNS OFF OUTPUT TIL READY
PSP      EQU      28                *UNUSED*
EOF      EQU      29                EOF IN CUR BLK (OUT)
CONT     EQU      30                SYMB OPERATION IN PROG
CONTCK   EQU      31                # OF REC ALLOWED/BLK SRB=1MRB=FF
CONTCNT  EQU      32                *UNUSED*
SCRC     EQU      33                *UNUSED*
HIP      EQU      34                HANG UP IN PROGRESS
BKD      EQU      35                *UNUSED*
TTYP     EQU      36                2780=1,IRBT=0
RTRY     EQU      37                NUMBER OF RETRIES
SPB      EQU      38                *UNUSED*
********************************************************
*          THE LINE HANDLER                            *
*                                                      *
*     THIS PART IS A MORE OR LESS ORDINARY DEVICE      *
*     HANDLER FOLLOWING THE SYSTEM RULES FOR HANDLERS  *
********************************************************
*
:DOT     CNAME
         PROC
LF       EQU      %-DOT
         GEN,8,8,8,8 BA(AF(1))-BA(DOT),AF(2),AF(3),AF(4)
         PEND
*
*******           *******           *******
*
T:SET    CNAME
FULL%DPX%ADDR,BACKEND%V,ACK%V,FCN%V  SET  0
DOT%X    SET      1                 INITIAL SUBSCRIPT VALUE
EVEN     SET      0
ODD      SET      1
*
         PROC
         ERROR,15,(AF(2)-BASE:)>255  'REORDERING NEEDED'
         ERROR,15,(AF(3)-BASE:)>255  'REORDERING NEEDED'
FULL%DPX%ADDR(DOT%X)  SET  AF(1)
BACKEND%V(DOT%X)     SET   AF(2)-BASE:
ACK%V(DOT%X)     SET    AF(3)-BASE:
DOT%X    SET      DOT%X+1
         PEND
*************************************
         PAGE
*                                   HANDLER FRONTEND ENTRY
2780IO   EQU      %                 :
         BAL,R11  BSC%PRE           GO DO STANDARD STUFF - IF
         CI,R5    27AK:DOT          WE ARE DOING ACK SEE IF ACK1
         BE       PRE%ACK           OR ACK0  IN ANY CASE GET
PRE%EXIT EQU      %                 FULL DUP EVEN ODD BIT FROM
         LB,R0    FCN%TAB,R5        DOT TABLE AND OFF TO COMLIST
         LI,R10   2780:DOT          VIA BSCIO
         B        RB%PREX
         SPACE    5
BASE:    EQU      %                 BASE FOR BYTE VECTORS
*
2780CU   EQU      %                 HANDLER BACKEND ENTRY
         BAL,R4   RB%CU             :
27GONE   B        BSC%GN            RB%CU SAYS:
         B        27CTO             HU GO TO HUNG UP ROUTINE
         LB,R6    POST%VEC,R5       TO GO TO TIME OUT ROUTINE
         B        BASE:,R6          AOK TAKE VECTOR FOR CUR FC
*
27CTO    EQU      %                 TIME OUT ROUTINE
         CI,R5    DISC:DOT          :
         BE       BSC%GN            IF IT WAS DISC WE'RE DONE
         CI,R5    27LG:DOT          LOGON HAS SPECIAL ERRLOG
         BE       ENQ%NOT           IF WE WERENT READING FOR ACK
         CI,R5    27RA:DOT          GO LOG TIMEOUT
         BNE      TO%OUT            :
         LB,R8    IOQ4,R3           IF CALLING FC WAS POL FOR
         CI,R8    27RA:DOT          INPUT WE'RE DONE
         BNE      27CTO1
         CW,R13   MORBIT            IS THIS ERROR POLL ?
         BANZ     %+3               NO
         LB,R5    RBB:HOU,R1        IS THIS OUTPUT ERROR ?
         BEZ      BSC%PX            NO.
         B        RPT%ORG           CONTINUE W/O ERROR LOG.
27CTO1   EQU      %
         MTB,2    R5                COUNT UP TIME-OUT ENTRY
         LI,R0    RPT%ORG           :
         B        LOG%ERR           OTHERWISE LOG TIME OUT
         PAGE
*THE :DOT PROC GENERATES - DUMMY CMD PTR,T.O. 5 SEC INCR,
*RTRY FC,FOLLOWON FC -- 8,8,8,8 -- FC IS DISP INTO :DOT TBL
*THE T:SET PROC GENERATES -- EVEN/ODD BIT TO PICK I/O ADDR
*IN FULL DUP,HANDLER BACKEND VECTOR,BACKEND SUB VECTOR IF
*READ FOR ACK IS EVER CALLED FROM THIS CALLING FC -- THE
*VALUES GO INTO VECTOR TABLES BELOW
*
DOT      SET      %                        AS CALLING FC (SEE RP RF)
2780:DOT EQU      DOT                      :
DISC:DOT :DOT     DS%,1,DISC:DOT,DISC:DOT  DISCONNECT LINE
         T:SET    EVEN,27GONE,RD%AK        :
27WR:DOT :DOT     WR%,1,27WR:DOT,27RA:DOT  WRITE DATA
         T:SET    ODD,WRT%BP,RD%AK         :
27SE:DOT :DOT     SE%,1,27SE:DOT,27RA:DOT  SEND ENQ (WAIT TO WRITE)
         T:SET    ODD,FOLLOWON,RD%AK       :
27AK:DOT :DOT     AK%,1,27AK:DOT,27RD:DOT  READ DATA (ACK0 1ST)
         T:SET    ODD,FN%CK,RD%ET          :
27WK:DOT :DOT     SW%,1,27WK:DOT,27RA:DOT  SEND WACK (WAIT TO READ)
         T:SET    ODD,FOLLOWON,W%AK        :
27WE:DOT :DOT     WR%,1,27WE:DOT,27RA:DOT  WRITE LAST BLOCK (EOF)
         T:SET    ODD,WRT%BP,SND%EOF       :
27P1:DOT :DOT     SE%,1,27P1:DOT,27RA:DOT  REQUEST TO OUTPUT (SND ENQ)
         T:SET    ODD,FOLLOWON,P%AK        :
27RA:DOT :DOT     RA%,1,27RA:DOT,27SE:DOT  POL FOR INPUT (READ FOR ACK,EOT,ENQ)
         T:SET    EVEN,POST%ACK,P2%AK      :
27LG:DOT :DOT     RA%,1,27LG:DOT,27AK:DOT  LOGON (READ FOR INIT ENQ)
         T:SET    EVEN,LG%CK,RD%ET         :
* BELOW FC'S NOT USED AS CALLING FC USE IN COMMENTS
*
27RD:DOT :DOT     RD%,2,27RD:DOT,27NK:DOT  READ DATA
         T:SET    EVEN,27INCK,RD%AK        :
27NK:DOT :DOT     NK%,1,27NK:DOT,27RD:DOT  SEND NAK
         T:SET    ODD,FOLLOWON,RD%AK       :
27A1:DOT :DOT     A1%,1,27A1:DOT,27RD:DOT  SEND ACK1
         T:SET    ODD,FN%CK,RD%AK          :
27ET:DOT :DOT     ET%,1,27ET:DOT           SEND EOT
         T:SET    ODD,POST%EXT,RD%AK
*
DOT%X    SET      DOT%X-1
         PAGE
:CLST    CNAME
         PROC
LF       GEN,8    DA(AF(1))-DA(DOT)
         PEND
*
AK%      :CLST    AKCOM
A1%      :CLST    AK1COM
WR%      :CLST    WRCOM
SE%      :CLST    SECOM
RA%      :CLST    RACOM             DUMMY COMMAND POINTERS
ET%      :CLST    ETCOM
SW%      :CLST    SWCOM
DS%      :CLST    DSCOM
RD%      :CLST    RDCOM
NK%      :CLST    NKCOM
         BOUND    4
*
*
*
XC7      DATA     X'C7'
MRLPBITS DATA     X'20000008'       LIPBIT AND MORBIT.
         PAGE
:CDW     CNAME
         PROC
LF       EQU      WA(%)
         DO       AF(2)=4
         GEN,8,24 CF(2),WA(AF(1))
         ELSE
         GEN,8,24 CF(2),BA(AF(1))
         FIN
         DO       NUM(CF)>3
         GEN,8,8,8,8     CF(3),CF(4),AF(2),AF(3)
         ELSE
         GEN,8,8,8,8     CF(3),X'80',AF(2),AF(3)
         FIN
         PEND
*
WRT      EQU      X'01'
RD       EQU      X'02'
DISO     EQU      X'0B'
FLG1     EQU      X'1E'
*
         BOUND    8
*
*                 SHELL COMMAND DOUBLEWORDS
*
*
AKCOM    :CDW,WRT,FLG1              BSCAKM,0,7
AK1COM   :CDW,WRT,FLG1              27AK1M,0,7
WRCOM    :CDW,WRT,FLG1              0,2
SECOM    :CDW,WRT,FLG1              27SEM,0,6
RACOM    :CDW,RD,FLG1,0             BSCSPC1,4,2
ETCOM    :CDW,WRT,FLG1              27ETM,0,6
SWCOM    :CDW,WRT,FLG1              27WKM,0,7
DSCOM    :CDW,DISO,FLG1             0,0
RDCOM    :CDW,RD,FLG1               0,2
NKCOM    :CDW,WRT,FLG1              BSCNAKM,0,6
*                 TABLE FOR FULL DUPLEX FUNCTION
*                     I/O  ADDRESSING.
*                 NECCESARY BECAUSE FULL DUPLEX OPTION
*                 LIMITS I/O FUNCTIONS TO CERTAIN
*                 I/O CHANNELS.
*
FCN%TAB  EQU      %
I        DO       DOT%X
         DATA,1   FULL%DPX%ADDR(I)
         FIN
         BOUND    4
*
       PAGE
*        POST   ENTRY   VECTOR     TABLE
*
POST%VEC EQU      %
I        DO       DOT%X
         DATA,1   BACKEND%V(I)
         FIN
         BOUND    4
*
         PAGE
*  BACKEND SUB VECTORR WHEN READ FOR ACK IS DONE
*
ACK%VEC  EQU      %
I        DO       DOT%X
         DATA,1   ACK%V(I)
         FIN
         BOUND    4
         PAGE
*
:CHAR    CNAME
         PROC
         BOUND    4
LF       EQU      %
I        DO       NUM(AF)
         GEN,8    AF(I)
         FIN
         PEND
*
*
*   SPECIAL MESSAGES : COMMAND DBL WRD BUFFERS
*
EIEIO    EQU      %       WITH A SYNC-SYNC HERE, AND A . . .
*                 SYNC-SYNC THERE, HERE A SYNC, THERE A SYNC,
*                 EVERYWHERE A SYNC-SYNC . . . . . . . . .
*
*
27SEM    :CHAR    SYNC,SYNC,SYNC,SYNC,ENQ,PAD
27ETM    :CHAR    SYNC,SYNC,SYNC,SYNC,EOT,PAD
27WKM    :CHAR    SYNC,SYNC,SYNC,SYNC,DLE,WACK,PAD
27AK1M   :CHAR    SYNC,SYNC,SYNC,SYNC,DLE,ACK1,PAD
27ETXM   :CHAR    ' ',' ',EM,ETX,X'5F',X'85'
37ETXM   :CHAR    ' ',' ',IRS,ETX,X'5D',X'B5'
         BOUND    8
37CHAR   DATA     IGS,IRS           LIMITS FOR 3780 SPECIFIC CHARS
37BUFDIF EQU      28
         PAGE
27INCK   EQU      %                 BACKEND OF READ DATA
         LW,R6    IOQ8,R3           :
         BAL,R12  BSC%GL            GET NEG BYTE COUNT AND 1ST
         CI,R5    ENQ               CHAR
         BE       ENQ%PRB           :
         CI,R5    EOT               IF 1ST IS ENQ ERROR IF EOT
         BE       27INRCVR          END OF INPUT ABORT STX-ENQ:NAK:EOT
         AND,R13  NMORBIT
         CI,R5    STX               :
         BNE      UNKN%RD1          SHOULD BE STX
         BAL,R10  BSC%FEC           :
         AI,R11   1                 :
         LW,R8    R11               CRC EACH RECORD PUTTING BYTE
         LI,R0    27CRC1            COUNT INCL ITBCRCCRC INTO
27CRC    EQU      %                 BYTE B4 1ST BYTE OF RECORD
         LW,R11   R8                WHICH WAS STX OR LAST BYTE OF
         LW,R7    R6                PREVIOUS CRC. -- 27CRC1 BELOW
         AI,R6    1                 TAKES CARE OF CONTROL CHARS
         BAL,R9   CRCI              :
         B        BD%CRC            TOGGLE ACK0-1 BIT AND GET LAST
         AI,R6    -1                CHAR.
         LW,R10   R6                :
         SW,R10   R7                IF ITS LOGON REC TEL RBBAT
         STB,R10  0,R7              AND ASSUME ETX
         AW,R8    R10               :
         BLZ      27CRC             IF ETB READ IS DONE
CRCDN    EQU      %                 :
         AI,R6    -2                IF ETX INITIATE ACK-EOT
         LB,R5    0,R6              SEQUENCE
         EOR,R13  BPBIT             :
         CI,R13   LIPBIT            IF NEITHER MUST BE ENQ- INIT
         BAZ      %+3               NAK-EOT SEQUENCE BUT KEEP BP
         BAL,R5   BSC%LGN           RIGHT IN CASE LINE HIT
         B        EXTOUT
         CI,R5    ETB
         BE       BSC%PX
         CI,R5    ETX
         BNE      FBP%ERR
EXTOUT   EQU      %
         AI,R13   FINBIT
         LI,R5    27AK:DOT
SET%FLO  STB,R5   IOQ4,R3           SET NEW CALLING FC
         B        NEW%FLO
**************************************************
PRE%ACK  EQU      %                 SELECT ACK1 OR ACK0
         CW,R13   BPBIT             :
         BAZ      PRE%EXIT          CALLED BY PRE ENTRY
         LI,R5    27A1:DOT          USES BPBIT TO CHOOSE ACK
         STB,R5   IOQ5,R3
         B        PRE%EXIT
****************************************************
27CRC1   EQU      %                 CRC CHAR CHECKER
         CI,R11   -2                :
         BGE      CRCI3             IF IN CRC IGNORE
         CI,R5    SYNC              :
         BE       CRCI4             IF SYNC DONT CRC
         CI,R5    ITB               :
         BNE      CRCI3             IF ITB END THIS RECORD
         LI,R11   -3
         B        CRCI3
*****************************************************
POST%ACK EQU      %                 BACKEND OF READ FOR ACK
         LH,R5    RBH:ACK,R1        :
         LB,R6    IOQ4,R3           GET RESPONSE INTO R5 AND
         LB,R6    ACK%VEC,R6        GO TO APP SUB VECTOR
         B        BASE:,R6
RD%AK    EQU      %                 SUBVEC FOR REAL READ FOR ACK1,0
         LI,R11   BSC%PX
ACK%CK   EQU      %                 CHECKER FOR REAL ACK0,1 READ
         LW,R6    BPBIT             :
         AND,R6   R13               COMPARE WITH APP ACK IF OK
         SCS,R6   1                 GO BACK
         CH,R5    AKS,R6            :
         BE       *R11              IF NAK LOG AND RETRY
ACK%CK1  EQU      %                 :
         SLS,R5   -8                OTHER STUFF LOG AND ENQ
         CI,R5    NAK
         BE       HE%NAKD
         CI,R5    EOT
         BE       27OURCVR          END OF OUTPUT ABORT EOTžACK
         B        UNKN%RD4
**********************************************
ZAPHIM   EQU      %                 LOG AND DISC ON INPUT ERROR
         LI,R0    E%DISC
         B        BD%BCB
***********************************************
27INRCVR EQU      %                 TERMINATE INPUT
         OR,R13   MORBIT
         AND,R13  NFINBIT
         LI,R5    27RA:DOT
         B        SET%FLO
***********************************************
27OURCVR EQU      %
         LI,R12   RCVRTYC           NOTIFY LINE MAN WITH NEW TYC
         B        BSC%PX1
**********************************************
SND%EOF  EQU      %                 SUBVEC FOR LST BLK WRT
         BAL,R11  ACK%CK            :
         LI,R5    27ET:DOT          IF ACK OK SEND EOT
         B        NEW%FLO
***********************************************
W%AK     EQU      %                 SUBVEC FOR SEND WACK
         SLS,R5   -8                :
         CI,R5    ENQ               IF RESP ENQ GET OUT
         BNE      ENQ%PRB           IF NOT LOG AND RETRY
POST%EXT B        BSC%PX
***********************************************
P%AK     EQU      %                 SUBVEC FOR REQ TO OUTPUT
         CI,R5    ACK0+DLE**8       :
         BNE      P%AK1             IF ACK0 REQ ACCEPTED
         LI,R12   PATYC             :
         B        BSC%PX1           IF NAK CHANGE CALLING FC TO
P%AK1    EQU      %                 POL FOR INPUT HE WONT LET US
         SLS,R5   -8                OUTPUT TO HIM
         CI,R5    NAK               IF NEITHER SEE IF WE GOT POL
         BNE      P2%AK+1           FOR INPUT BACK
         LI,R5    27RA:DOT
         B        SET%FLO
P2%AK    EQU      %                 SUBVEC FOR POL FOR INPUT
         SLS,R5   -8                :
         CW,R13   MORBIT
         BANZ     P2%AKM
         CI,R5    ENQ               IF ENQ POL RECIEVED
         BNE      ENQ%PRB           UNRECOGNIZED : LOG ERR
         LI,R12   PRTYC             IF NOT POL FAILED
         B        BSC%PX1
P2%AKM   EQU      %
         CI,R5    ENQ               IF POL RECEIVED ENTER FRESH ACK-READ
         BNE      RPT%ORG           OTHERWISE REPEAT POLL
         AND,R13  NBPBIT
         LI,R5    27AK:DOT
         B        SET%FLO
****************************************************
RD%ET    EQU      %                 SUBVEC FOR READ EOT AFTER
         SLS,R5   -8                ETX ACK'ED
         CI,R5    ENQ               :
         BE       ENQ%PRB           IF ENQ OR NOT EOT LOG AND
         CI,R5    EOT               REPEAT ACK
         BNE      LGN%ACK           :
         AI,R13   -FINBIT           IF EOT GIVE EOF TO CALLER
         LI,R12   LEOFTYC           DIFFERENT AND SEND ACK AGAIN
         B        BSC%PX1
***************************************************
FBP%ERR  EQU      %                 CALLED BY 27INCK ABOVE
         EOR,R13  BPBIT
         B        UNKN%RD3
***************************************************
WRT%BP   EQU      %                 BACKEND OF WRITE DATA
         LB,R11   IOQ10,R3          :
         CB,R11   IOQ11,R3          IF NOT A RETRY TOGGLE
         BNE      BSC%FL            ACK0-ACK1 BIT
         EOR,R13  BPBIT             AND READ FOR ACK
FOLLOWON B        BSC%FL
****************************************************
FN%CK    EQU      %                 SUBVEC FOR SEND ACK
         CI,R13   FINBIT            :
         BAZ      BSC%FL            IF WE READ ETX READ
         LI,R5    27RA:DOT          FOR EOT
         B        NEW%FLO
***************************************************
LG%CK    EQU      %                 BACKEND 4 LOGON RD 4 ENQ
         LH,R5    RBH:ACK,R1        :
         CI,R5    ENQ+SOH**8        IF ITS SOH ENQ IT MUST BE
         BE       HSP%CK            AN IRBT -- IF NO IRBT HANG UP
         SLS,R5   -8                LINE OTHERWISE LET HASPIO
         CI,R5    ENQ               TAKE OVER.
         BNE      ENQ%NOT           :
         LI,R9    BAGMBSZ           IF ITS NOT ENQ AT ALL LOG
         STH,R9   IOQ9,R3           AND READ AGAIN
         LI,R5    27AK:DOT          :
         B        SET%FLO           IF IT IS ENQ SET UP TO READ
HSP%CK   EQU      %                 LOGON RECORD INTO MPOOL
         LI,R9    HASPIO            SUPPLIED BY RBBAT AND FALL
         BEZ      ZAPHIM            INTO READ CODE
         STW,R9   DCT8,R1
         LI,R9    HASPCU
         STW,R9   DCT9,R1
         OR,R13   HASPBIT
         EOR,R13  2780BIT
         B        H%LGST
AKS      DATA,1   DLE,ACK0,DLE,ACK1
BAGMBSZ  EQU      GMBSIZ+GMBSIZ+GMBSIZ+GMBSIZ
*************************************************
****************************************************
*                                                  *
*                 THE BLOCK BUILDER                *
*                                                  *
****************************************************
27B      EQU      %                 BEGINING OF BUILD ENTRY
         LI,R1    STX               :
         STB,R1   0,R3              PUT STX IN BUFFER AND STORE
         AI,R3    1                 AWAY POB
         STW,R3   POB,R6
27BG     EQU      %                 MIDDLE OF BUILD ENTRY
         LB,R4    RBB:HOU,R7        :
         LB,R5    STB:Q,R4          IF THERE IS NO DATA READY
         BEZ      27BO              OR WE AREN'T READY TO START
         LW,R9    SAB,R6            BUILDING OR SOMEONE IS
         BNEZ     BSC%BO1           WAITING FOR US - EXIT
         LH,R9    IOQ9,R5           :
         BEZ      27BEF             IF THE BC IS ZERO ITS A
         LW,R2    RST,R6            WRITE EOF FROM SYMB.
         BEZ      %+4               IF SYMB RESTART DONT WRITE
         LI,R2    0                 FIRST LINE.
         STW,R2   RST,R6
         B        27RI1+1
         LB,R2    STB:TYP,R4        WRITE EOF FRROM SYMB
         CI,R2    PUTYP             :
         BNE      27PR              IF ITS PUNCH AND EMBIT IS
27PU     EQU      %                 SET DONT TRUNCATE - IF THE
         LW,R15   RB:FLAG,R7        TRUNK IS DONE AND THE REC
         CI,R15   EMBIT             IS STILL >= 80 BYTES TELL
         BANZ     27PU1             27RI NOT TO PUT EM IN
         LB,R1    RBB:CPZ,R7        :
         BAL,R11  27TRNK            THEN CLOSE OFF LAST REC,
         CI,R9    80                SET UP PUN SELECT AND
         BL       27PU1             GO PUT THE REC IN THE BUF
         AI,R15   EMBIT             :
27PU1    EQU      %                 IF THE RECORD IS PRINT WE
         BAL,R10  27SS              MUST CONVERT VFC TO SELECT
         LI,R2    PUESC             CODES.  -- SINCE THE 2780
         B        27RI              SPACES AND SKIPS AFTER AND
27UPSP   EQU      %                 WE DO SO B4, THE ACTUAL
         AND,R15  M4                DATA ALWAYS HAS A PRINT AND
         BEZ      27NP              UPSPACE SELECT.  -- ALL VFC
         BAL,R10  27SS1             IS HANDLED BY INSERTING EXTRA
         AI,R15   X'C0'-1           MESSAGES WITH THE APPRROPRIATE
         STW,R15  FCSI,R6           CODES.  - FCSI IS USED TO
         LI,R2    PRESC             REMEMBER THE CURRENT REMAINING
         B        27PR1             VFC IN CASE WE CROSS A BLOCK
27PR     EQU      %                 BOUNDARY WHILE WRITING
         LW,R15   FCSI,R6           THE EXTRA MESSAGES.
         BNEZ     %+3               :
         LW,R2    IOQ8,R5           WHEN WE FINALLY GET TO THE
         LB,R15   0,R2              ACTUAL DATA WE STRIP TRAILING
         CI,R15   X'C0'             BLANKS FROM THE RBB:LPZ LENGTH
         BLE      27NP              SET UP THE PRINTER UPSPACE
         CI,R15   X'10'             SELECT, AND GO TO PUT THE
         BAZ      27UPSP            RECORD IN.  -- WE ALWAYS USE
         AND,R15  XC7               AN EM FOR PRINT RECORDS
         BAL,R10  27SS1
         LI,R10   X'C0'
         STW,R10  FCSI,R6
         LW,R2    R15
27PR1    EQU      %
         BAL,R11  CRC1
         LI,R2    ' '
         BAL,R11  CRC1
         LW,R11   OCRCB,R6
         BNEZ     %+3               3780 TEST
         LI,R2    EM
         BAL,R11  CRC1
         STW,R3   POB,R6
         B        27PR
27NP     EQU      %
         LH,R9    IOQ9,R5
         AI,R9    -1
         BAL,R10  27SS
         MTW,1    IOQ8,R5
         LB,R1    RBB:LPZ,R7
         BAL,R11  27TRNK
         LI,R2    PRESC
         LI,R15   0
27RI     EQU      %                 INSERT DATA RECORD INTO BLOCK
         BAL,11   CRC1              :
         LW,R2    IOQ8,R5           THE SELECT CHAR IN R2 IS
         LW,R11   OCRCB,R6
         BNEZ     37SC              3780 TEST
         LI,R10   CRCO3             CRC'ED INTO THE BLK
         BAL,R11  CRCX              :
         STW,R12  CCRC,R6           THEN THE DATA IS MOVED IN
         CI,R15   EMBIT             AND CRC'ED
         BANZ     %+3               :
         LI,R2    EM                IF THE TEMP EMBIT IN R15
         BAL,R11  CRC1              IS NOT SET AN EM IS CRC'ED
27RI2    EQU      %
         LI,R12   0                 IN
         STW,R12  FCSI,R6           :
         STW,R3   POB,R6            WE THEN CLEAR FCSI AND FIX
27RI1    EQU      %                 POB, GIVE THE CALLING SYMB
         LB,R5    STB:Q,R4          PSEUDO END ACTION AND GO OFF
         LI,R8    27BG              TO TRY TO PUT A NEW RECORD IN
         B        ENDAC
27BO     EQU      %                 BUILDER EXIT
         LW,R14   FBF,R6            --- IF FORCED CLOSE THE BUF
         BNEZ     27BCL             ELSE JUST EXIT
         B        BSC%BO
27TRNK   EQU      %                 STRIP TRAILING BLANKS
         CW,R1    R9                :
         BLE      %+2               ENTER WITH THE MAX REC LENGTH
         LW,R1    R9                IN R1
         AW,R1    IOQ8,R5           STRIP TRAILING BLANKS FROM THERE
         LI,R2    ' '               CORRECTING THE BYTE COUNT
         AI,R1    -1                IN R9 (BUT DONT LET IT GO
         CW,R1    IOQ8,R5           TO ZERO
         BLE      %+3
         CB,R2    0,R1
         BE       %-4
         AI,R1    1
         SW,R1    IOQ8,R5
         LW,R9    R1
         B        *R11
******************                  CHARACTER CHECK:
37SC     EQU      %                 COMPRESS BLANKS & CRC
         LW,R5    R2
         LB,R2    0,R5
         CI,R2    BLNK
         BNE      37SC2
         LW,R1    R5
         STB,R9   R1
         CBS,0    BA(BLANK)
         BCR,3    %+2               SPECIAL CASE: TRAILING BLANKS
         MTB,1    R1
         LB,R8    R1
         SW,R9    R8
         BEZ      37SC1
         LI,R2    IGS
         BAL,R11  CRC1
         LI,R2    X'41'
         AW,R2    R9
         AI,R9    -1
         LCW,R9   R9                SAVED THIS MANY CHARS
         AWM,R9   RBC,R6
         BAL,R11  CRC1
         LW,R9    R8
         BEZ      27RI2
         AI,R9    -1
         AND,R1   M24
         LW,R5    R1
         LB,R2    0,R1
37SC2    EQU      %
         BAL,R11  CRC1
         AI,R5    1
         LW,R2    R5
         BDR,R9   37SC
         B        27RI2
37SC1    EQU      %
         LW,R9    R8                SPECIAL CASE: 1 BLANK
         B        37SC2
*************************************************
27FL     EQU      %                 CLOSE OFF OLD RECORD IF ANY
         LW,R3    POB,R6            :
         LW,R11   CURF,R6           IF NO RECS IN BLK YET
         BEZ      0,R1              EXIT 0,R1
         MTW,1    CURF,R6           :
         BAL,11   CRC1              OTHERWISE CRC IN CLOSE CHAR
         LW,R11   OCRCB,R6
         BNEZ     37FL1             3780 TEST
27FL1    EQU      %
         STB,R12  0,R3              IN R2 AND STORE IN THE CRC
         SLS,R12  -8                :
         AI,R3    1                 COUNT THE RECORD,FIX POB,
         STB,R12  0,R3              AND SET THE CCRC TO ZERO
         AI,R3    1                 :
         LI,R12   0
         STW,R12  CCRC,R6
37FL1    EQU      %
         STW,R3   POB,R6
         B        1,R1
27SS     EQU      %                 PREPARE TO INSERT NEXT RECORD
         AWM,R9   RBC,R6            IF THERE IS ROOM
27SS1    EQU      %                 :
         MTW,7    RBC,R6            IF THE BLOCK IS FULL
         MTW,1    RBC,R6            BECAUSE THERE IS NO ROOM OR
         BGZ      27BCL             IT HAS THE MAX # OF RECS
         LW,R2    CURF,R6           CLOSE OFF THE BLOCK
         CW,R2    CONTCK,R6         :
         BGE      27BCL             OTHERWISE CLOSE OFF THE LAST
         LW,R2    OCRCB,R6
         BNEZ     %+2               3780 TEST
         LI,R2    ITB               REC WITH AN ITB
         BAL,R1   27FL              :
         B        27FL3             PUT IN AN STX ESC (CRC'ED)
         LI,R2    STX               IF THIS IS NOT THE FIRST
         BAL,R11  CRC1              REC AND JUST A CRC'ED ESC IF
         B        %+2               THIS IS THE FIRST
27FL3    EQU      %                 :
         MTW,1    CURF,R6           NOTE THAT THE RECS ARE COUNTED
         LI,R2    ESC               TWICE BUT THIS IS OK BECAUSE
         BAL,R11  CRC1              WE ARE ALLOWED EITHER 1 OR
         B        *R10              AS MANY AS WILL FIT
**************************************************************
27BEF    EQU      %                 EOF FROM SYMB
         STW,R9   RST,R6            :
         LI,R2    ETX               :
         BAL,R1   27FL              CLOSE OFF LST REC W/ETX
         B        27BEFN            :
         LW,R1    OCRCB,R6
         BEZ      27BEF1            3780 TEST
         LI,R1    27BEF1-1
         B        27FL1
27BEF1   EQU      %                 IF NO RECS IN BLK PUT IN
         LI,R8    0                 A DUMMY FOR THE ETX TO
         STB,R8   RBB:HOU,R7        SIT ON
         MTW,-1   EOF,R6            :
27BEF2   LI,R8    BSC%BC            CLEAR THE CURRENT OUTPUT
         LI,R12   0                 SYMB,SET THE EOF FLAG,
         B        ENDAC             GIVE HE SYMB PSEUDO END
27BEFN   EQU      %                 ACTION, AND GO TO THE
         LW,R9    R3                BLOCK CLOSER
         LI,R8    BA(27ETXM)
         LW,R3    OCRCB,R6          3780 TEST
         BEZ      %+2
         LI,R8    BA(37ETXM)
         MTB,6    R9
         MBS,R8   0
         LW,R3    R9
         STW,R3   POB,R6
         B        27BEF1
27BCL    EQU      %                 CLOSE BLOCK (NOT LAST)
         LW,R2    OCRCB,R6
         BEZ      27BCL1            3780 TEST
         BAL,R1   27FL
         B        BSC%BC
27BCL1   EQU      %
         LI,R2    ETB               :
         BAL,R1   27FL              CLOSE LAST REC W/ETB
         B        BSC%BC            AND GO TO THE BLOCK
         B        BSC%BC            CLOSER
***************************************************
****************************************************
*                                                  *
*              THE BLOCK PARSER                    *
*                                                  *
****************************************************
27P      EQU      %                 BEGINING OF PARSE ENTRY
         LB,R4    RBB:HIN,R7        :
         BEZ      BSC%EOB           IF THERE IS NO ACTIVE INPUT
         LB,R5    STB:Q,R4          SYMB WE MUST HAVE READ A
         BEZ      BSC%PO            FIN SO WE THROW AWAY ANY DATA
         LB,R9    0,R2              :
         AI,R9    -3                IF THERE IS NO ONE TO GIVE
         BLEZ     27PEF1            THE DATA TO - EXIT
         AI,R2    1                 :
27P1     EQU      %                 PICK UP THE BYTE COUNT AND
         LB,R10   0,R2              SUBTRACT OFF THE CLOSER AND
         CI,R10   STX               CRC
         BE       %+3               :
         CI,R10   SYNC              IGNORE ANY LEADING STX AND/OR
         BNE      27P15             SYNCS
         AI,R2    1                 :
         AI,R9    -1                MOVE THE DATA TO THE
         B        27P1              CALLER'S BUFFER
27P15    EQU      %                 :
         LW,R3    IOQ8,R5           IF THERE WAS AN EM BLANK
         LW,R10   OCRCB,R6
         BNEZ     37P15I            3780 TEST
         STB,R9   R3                FILL TO 80 BYTES
         MBS,R2   0                 :
         AI,R2    -1                IN ANY CASE GIVE THE SYMB
         LB,R14   0,R2              PSEUDO END ACTION
         CI,R14   EM                :
         BNE      BSC%PEA           AFTERWARDS LOOK AT THE
27P16    EQU      %
         LI,R10   81                CLOSE CHAR:  IF ITB GO TO
         LW,R1    R3                PARSE THE NEXT REC.  IF ETB
         AI,R1    -1                ITS THE END OF THIS BLOCK
         SW,R10   R9                IF ETX FALL INTO EOF CODE
         STB,R10  R1                :
         MBS,0    BA(BLANK)         27P2 IS MIDDLE OF PARSE
         LW,R3    R1                ENTRY SO THAT EOF WORKS
         B        BSC%PEA           SMOOTHLY
37P15I   EQU      %                 CHARACTER CHECK:
         LW,R8    R9                  IRS - OVERWRITE WITH BYTE COUNT
37P15    EQU      %                   IGS - DECOMPRESS BLANKS
         LB,R10   0,R2
         CLM,R10  37CHAR
         BCS,9    37P16
         BCR,4    37P17
         AI,R2    1
         LB,R10   0,R2
         LW,R1    R3
         AND,R10  M6
         STB,R10  R1
         MBS,0    BA(BLANK)
         LW,R3    R1
         AI,R9    -2
         AI,R2    1
         B        37P15
37P16    EQU      %
         STB,R10  0,R3
         AI,R2    1
         AI,R3    1
         BDR,R9   37P15
         B        27PEF
37P17    EQU      %
         SW,R8    R9
         AI,R9    3
         STB,R9   0,R2
         LW,R9    R8
         AI,R2    -1
         AI,R3    1
         B        27P16
37P2     EQU      %
         AI,R2    1
         LB,R15   0,R2
         CI,R15   ETB
         BE       BSC%EOB
         CI,R15   ETX
         BE       27PEF
         AI,R2    -1
         B        27P
27P2     EQU      %
         LW,R10   OCRCB,R6
         BNEZ     37P2              3780 TEST
         LB,R15   0,R2
         AI,R2    2
         CI,R15   ITB
         BE       27P
         CI,R15   ETB
         BE       BSC%EOB
27PEF    EQU      %                 END-OF-FILE ENTRY
         LB,R4    RBB:HIN,R7        :
         LB,R5    STB:Q,R4          WAIT TILL THERE IS A
         BEZ      BSC%PO            READ TO GIVE THE EOF TO
27PEF1   EQU      %                 :
         LH,R12   IOQ9,R5           THEN GIVE PSEUDO END ACTION
         OR,R12   EOFTYC            WITH AN EOF TYC
         BAL,R8   ENDAC1            :
         LI,R8    0                 CLEAR THE INPUT SYMB AND
         STB,R8   RBB:HIN,R7        FREE THE BUFFER
         B        BSC%EOB
**********************************************
*****************************************************
*                                                   *
*             THE LINE MANAGER                      *
*                                                   *
*****************************************************
VEC      COM,8    AF(1)-27CB:
27CVC    EQU      %
         VEC      27CB:
         VEC      27WRT
         VEC      27WRT
         VEC      27RD              VECTORS BY FC FOR LINE
         VEC      27RD1             CONTROLLER
         VEC      27ETOUT
         VEC      27POL
         VEC      27POL
**********************************************
27CTL    EQU      %                 CONTROL ENTRY
         LW,R1    CFC,R6            GO TO APP VECTOR BY
         LB,R1    27CVC,R1          CURRENT FC
27CB:    B        27CB:,R1
27RD     EQU      %                 FUNCTION WAS READ
         LW,R2    CRB,R6            :
         LI,R15   HPB               FREE THE CURRENT READ
         BAL,R11  BSC%FB            BUFFER
         CI,R3    LEOFTYC           :
         BNE      27RD1             IF IT WASN'T EOF GO TO
         MTW,-1   CONT,R6           READ NXT BLK
         LB,R4    RBB:HOU,R7        INPUT COMPLETE : GIVE OUTPUT
         BEZ      27RD2             SYMBIONT ENDACTION AND RESUME
         LI,R10   0
         STB,R10  RBB:HOU,R7        ZERO CURRENT OUTPUT HEAD
         STW,R4   CURX,R6           NORMAL OPERATION
         LI,R10   0
         LW,R11   BPBIT             RESET BPBIT WHEN RESUMING
         STS,R10  RB:FLAG,R7        OUTPUT FROM ERROR RECOVERY.
27RD2    EQU      %
         LI,R11   0
         XW,R11   CIP,R6            IF EOF CLR OP IN PROG
         B        BSC%PRS           AND EXIT VIA PARSE
27RD1    EQU      %
         LI,R15   HRB               FC WAS WACK OR READ
         BAL,R11  BSC%GB            :
         BEZ      27WAK             IF NO RD BUF SEND WACK
         STW,R2   CRB,R6            :
         LW,R13   CRB,R6            OTHERWISE DO NXT READ
         LI,R14   BUFSZ             :
         LW,R10   OCRCB,R6
         BEZ      %+2               3780 TEST
         AI,R14   37BUFDIF**2
         LI,R12   RDFCN
27DIO    EQU      %                 DO REAL I/O
         AI,R13   1                 :
         SLS,R13  2                 ENTER W/:R13=BUF,R14=BC
27DIO1   EQU      %                 R12=FC
         STW,R12  CFC,R6            :
         AND,R13  M24               DO I/O VIA BSCIO
         BAL,R10  BSCDIO            :
         PLW,R11  TSTACK            AFTER I/O CALL BUILD OR
         LW,R10   HPB,R6            PARSE AS APPROPRIATE
         BNEZ     BSC%PRS
         LB,R10   RBB:HOU,R7
         BNEZ     BSC%BLD
         B        *R11
27WRT    EQU      %                 FC WAS WRITE OR SND ENQ
         CI,R3    RCVRTYC
         BNE      27WRT1            ERROR WAS DETECTED
         LB,R4    RBB:HOU,R7        IF SYM IS THERE, SUSPEND BUILD
         BNEZ     27WRT2            AND COLLECT ALL BUFFERS FOR READ.
         LI,R13   27ETOUT           OTHERWISE FREE ALL BUFFERS AND
         B        27CLRBF           GET OUT.
27WRT2   EQU      %
         STW,R3   SAB,R6
27CLEAR  EQU      %
         LI,R13   27COUT
27CLRBF  EQU      %
         LW,R11   BIP,R6            GATHER BUFFERS : IF BIP
         BNEZ     27FRCRD           SET MUST FORCE READ. OTHER-
27CLRLP  EQU      %
         LI,R15   HWB               WISE TAKE WR BUFS TO HBB.
         BAL,R11  BSC%GB
         BEZ      *R13
         LI,R15   HBB
         BAL,R11  BSC%FB
         B        27CLRLP
27FRCRD  EQU      %                 FORCE READ :
         LI,R11   27CLEAR           WHEN BUILD DONE, WILL RETURN
         XW,R11   BIP,R6            TO US WHERE WE USE BIP EXIT
         XW,R11   CIP,R6            AND USE OUR OWN NOW.
         B        *R11
27WRT1   EQU      %
         LI,R15   HWB               :
         BAL,R11  BSC%GB            CWB IS FREED BY ML%CTL
         BEZ      FORCWR            IN BSCIO
         STW,R2   CWB,R6            :
         LW,R13   CWB,R6            IF NO WRITE BUFFS TRY TO
         MTW,1    CWB,R6            FORCE ONE FULL - BACK TO
         LI,R12   WRFCN             27WRT IF IT WORKS
         LW,R14   4SYNC             :
         XW,R14   1,R2              IF NECESSARY CHANGE FC TO WEOF
         LW,R15   EOF,R6            :
         AW,R15   HWB,R6            AND GO DO THE WRITE
         BGEZ     27DIO
         MTW,1    EOF,R6
         LI,R12   WEOFCN
         B        27DIO
27POL    EQU      %                 FC WAS POL OR REQ WRT
         LI,R15   0                 :
         CI,R3    PRTYC             GO TO APP ROUTINE IF WE CAN
         BE       27SI              DO SOMETHING - OTHERWISE EXIT
         CI,R3    PATYC             AND CLEAR OP IN PROG
         BE       27SO
27ETOUT  EQU      %                 FC WAS WEOF
27COUT   EQU      %                 OR POL-REQ FAILED
         MTW,-1   CONT,R6
         LI,R14   CIP
         B        BSC%GO
27SI     EQU      %                 START INPUT
         XW,R15   HBB,R6            :
         BEZ      %+2               MOVE ALL BUFFS TO HRB
         STW,R15  HRB,R6            :
         LB,R3    RBB:HFE,R7        SET UP IN SYMB ACTIVE
         LB,R11   SSIG,R3           :
         BNEZ     27COUT            UNLESS LAST OP NOT DONE
         STB,R3   RBB:HIN,R7        :
         LI,R11   27RD1             START SYMB AND FALL INTO RD
         B        27SQI
27SO     EQU      %                 START OUTPUT
         XW,R15   HRB,R6            :
         BEZ      %+2               MOVE ALL BUFFS TO HBB
         STW,R15  HBB,R6            :
         LI,R3    0                 GET THE SYMX SAVED BY
         STW,R3   SAB,R6            THE SYMB MNGR AND LET HIM
         XW,R3    CURX,R6           START TO FILL BUF
         STB,R3   RBB:HOU,R7        :
         LB,R5    STB:Q,R3          IF HE HAS I/O READY GO
         BNEZ     FORCWR            TRY TO GET A FULL BUF
27WENQ   EQU      %                 :
         LI,R12   ENQFCN            IF NOT OR IF FORCE WRITE
         B        27DIO1            FAILS WRITE ENQ
27WAK    EQU      %
         LI,R12   WACKFCN           WRITE WACK
         B        27DIO1
*********************************************************
27SQI    EQU      %                 START A SYMB
         LW,R15   BPBIT             :
         LI,R14   0                 ZERO BPBIT FOR CLEAN START
         STS,R14  RB:FLAG,R7
         LI,R1    'I'
         STB,R1   SSIG,R3
         B        SAQNSERT
***************************************************
27HU     EQU      %                 HANG UP ENTRY
         LB,R4    RBB:HIN,R7        :
         BAL,R8   27HEA             GIVE PSEUDO END ACTION
         LB,R4    RBB:HOU,R7        TO ANY SYMBS THAT MAY STILL
         AW,R4    CURX,R6
         BAL,R8   27HEA             GIVE PSEUDO END ACTION
         LI,R2    0
         STB,R2   RBB:HIN,R7        RBBAT WAITS FOR HIN & HOU TO
         STB,R2   RBB:HOU,R7        GO ZERO B4 COMPLETING HANGUP
         B        BSC%HO
27HEA    EQU      %
         BEZ      *R8
         LB,R5    STB:Q,R4
         BEZ      *R8
         B        BSC%HEA
***************************************************
********************************************************
*                                                      *
*            THE SYMBIONT MANAGER                      *
*                                                      *
*CALLED BY RBSS OFF THE 5 SECOND CLOCK                 *
********************************************************
27SSS    EQU      %                 LOOK FOR HANG UPS OR
         LI,R14   0
         LI,R15   CTRBIT+LIPBIT     DIAL UPS - RB%TDV HANDLES
         BAL,R5   RB%TDV            DU - 27TDVF HANDLES HU
         B        27TDVF
27NN     EQU      %                 SEE IF WE ARE ALREADY ACTIVE
         CW,R13   MRLPBITS
         BANZ     NXT%DEV           DONT DO ANYTHING IF
         LW,R6    RB:BUF,R7         LOGGING ON
         BEZ      NXT%DEV           :
         LW,R14   CONT,R6           EXIT IF ANYTHING IS
         AW,R14   HPB,R6            ALREADY GOING ON
         AW,R14   CPB,R6            :
         BNEZ     NXT%DEV           OTHERWISE SET OP IN PROG
         MTW,1    CONT,R6           :
         LW,R3    CURX,R6           IF WE HAVE PICKED AN OUTPUT
         BNEZ     27STRTO           SYMB, REQ OUTP AGAIN
         LB,R3    RBB:HOU,R7        IF OUTP SYMB WAITING ON INPUT
         STW,R3   RST,R6            SET FLAG FOR 1ST LINE ABORT AND
         BNEZ     27STRTI           GO START INPUT SYMB
         LB,R3    RBB:HFE,R7        :
27NN1    EQU      %                 OTHERWISE TRY TO FIND OUT
         LB,R3    STB:LNK,R3        SYMB WITH STP AND NO LOCK
         BEZ      27STRTI           :
         LH,R2    STH:FLG,R3        IF ONE IS FOUND START HIM,
         CI,R2    LOCBIT            SAVE HIS INDEX IN CURX, BUT
         BANZ     27NN1             SET SAB TO KEEP HIM FROM
         CI,R2    STPBIT            GETTING BUFFER YET
         BAZ      27NN1             :
         STW,R3   CURX,R6           THEN DO AN OUTPUT REQUEST
         STW,R3   SAB,R6            :
         BAL,R11  27SQI             :
27STRTO  EQU      %                 IF NO OUTPUT SYMB IS FOUND
         LI,R12   POL1FCN           AND NO RBDISC HAS BEEN SENT
27STRT   EQU      %                 START UP A POL FOR INPUT
         LI,R11   NXT%DEV           :
         STW,R11  CIP,R6            IF THERE WAS AN RBDISC SET
         B        27DIO1            RBXBIT TO DISC LINE
27STRTI  EQU      %
         LI,R12   POL2FCN
         BAL,R1   BSC%DSC
         B        27STRT
         B        27STRT
27TDVF   EQU      %                 HANG UP OCCURED
         CI,R13   LIPBIT+ACTBIT     :
         BAZ      NXT%DEV           IF NOONE ELSE HAS NOTICED
         CW,R13   HUBIT             TELL RBBAT AND EVERYONE ELSE
         BANZ     NXT%DEV
         LI,R12   HUP
         LI,R14   0
         LW,R15   HUBIT
         B        RBSGCQ1
***************************************************
         END

