         DEF      2780IO:
2780IO:  EQU      %
*********************************************************
*     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
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
********
         REF      Y004,Y008,Y01,Y02,Y04,Y08
         REF      Y1,Y2,Y4,Y8,RBB:LPZ,RBB:CPZ
         REF      CRC1,STB:Q,ENDAC,BSC%PEA,STB:TYP
         REF      ENDAC1,IOQ8,STH:FLG,CRCI,BSC%EOB
         REF      IOQ9,CRCI3,RBB:HIN,CRCO,M4,RBB:HOU
         REF      BSC%BC,BLANK,CRCI4,OLD%BCB1,X1,M24
         REF      TSTACK,BSCAKM,BSCDIO,FORCWR,BSCNAKM
         REF      BSC%FB,RBB:HFE,BSCSPC1,BSC%GB,SAQNSERT,SSIG
         REF      BD%CRC,UNKN%RD1,BSC%GL,4SYNC,IOQ5
         REF      BSC%PRE,NEW%FLO,RB%PREX,E%DISC,ENQ%PRB
         REF      RBH:ACK,IOQ4,BSC%PX,BSC%PX1,BSC%FL
         REF      BSC%BLD,BSC%GN,BSC%GO,BSC%PRS,RB%CU
         REF      ENQ%NOT,HE%NAKD,UNKN%RD3,UNKN%RD4,BD%BCB
         REF      IOQ10,IOQ11,Y07,BSC%PO,BSC%BO
         REF      HUP,STB:LNK,NXT%DEV,RB%TDV,RB:BUF,RB:FLAG,RBSGCQ1
         REF      BSC%LGN,LGN%ACK,DCT8,DCT9,GMBSIZ,Y002
         REF      BSC%BO1,TO%OUT,BSC%HO,BSC%HEA
         REF      BSC%DSC,CRCX,CRCO3
         SREF     HASPIO,HASPCU,HAR:DOT,H%LGST
         DEF      27HU,27CTL,27DIO1,27WRT
         DEF      27B,27BG,27P,27PEF,27P2,27SSS
         DEF      2780IO,2780CU,2780BIT
**********************************************
*
*        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'
*                                   BIT DEFINITIONS FOR RB:FLAG
*                                   SEE DB 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
*
SYNC     EQU      X'32'
SOH      EQU      X'01'
STX      EQU      X'02'
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
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
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
         BE       BSC%PX
         B        TO%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'
         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
         GEN,8,8,8,8    CF(3),X'80',AF(2),AF(3)
         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               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'
         BOUND    4
         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       ZAPHIM            END OF INPUT ABORT STXENQ-NAK-EOT
         CI,R5    STX               :
         BNE      UNKN%RD1          SHOULD BE STX
         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
         B        UNKN%RD4
**********************************************
ZAPHIM   EQU      %                 LOG AND DISC ON INPUT ERROR
         LI,R0    E%DISC
         B        BD%BCB
**********************************************
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                :
         CI,R5    ENQ               IF ENQ POL RECIEVED
         BNE      BSC%PX            :
         LI,R12   PRTYC             IF NOT POL FAILED
         B        BSC%PX1
****************************************************
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
         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
         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
         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
         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
*************************************************
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
         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                 :
         STW,R3   POB,R6            THEN EXIT 1,R1
27FL1    LI,R12   0
         STW,R12  CCRC,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
         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
         LI,R2    ETX               :
         BAL,R1   27FL              CLOSE OFF LST REC W/ETX
         B        27BEFN            :
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)
         MTB,6    R9
         MBS,R8   0
         LW,R3    R9
         STW,R3   POB,R6
         B        27BEF1
27BCL    EQU      %                 CLOSE BLOCK (NOT LAST)
         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
         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
         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
27P2     EQU      %
         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
         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             :
         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
         LB,R10   RBB:HOU,R7        PARSE AS APPROPRIATE
         BNEZ     BSC%BLD
         LW,R10   HPB,R6
         BNEZ     BSC%PRS
         B        *R11
27WRT    EQU      %                 FC WAS WRITE OR SND ENQ
         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
         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
         LI,R8    BSC%HO            BE ACTIVE
         AW,R4    CURX,R6
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,R11   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
         CI,R13   LIPBIT            :
         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: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,R11   HUBIT
         B        RBSGCQ1
***************************************************
         END

