V2IO:    EQU      %
         DEF      V2IO:             FOR XDELTA SYMBOL
*
*
*M*      V2IO     VISTA 2 HANDLER FOR TRANSACTION PROCESSING
*
*
*P*      NAME:    V2IO
*P*
*P*      PURPOSE: HANDLER FOR VISTA II CRT TERMINALS USED IN
*P*               TRANSACTION PROCESSING
*P*
*P*      DESCRIPTION:
*P*               V2IO IS ESSENTIALLY A STANDARD CP-V DEVICE
*P*               HANDLER, ACCEPTING FUNCTION CODES FROM THE I/O
*P*               SYSTEM AND RETURNING TYPES-OF-COMPLETE.  SINCE IT
*P*               IS A TRANSACTION PROCESSING HANDLER IT HAS A FEW EXTRA
*P*               JOBS TO PERFORM:
*P*
*P*               1)  IT ACCEPTS ON INPUT A FOUR WORD BUFFER (POINTED
*P*               TO BY THE END-ACTION INFORMATION IN ITS IOQ ENTRY)
*P*               THAT CONTAINS:
*P*
*P*                         A. A POLLING-SELECTION LIST ADDRESS
*P*
*P*                         B. OPTIONALLY A POLLING-SELECTION START
*P*                         INDEX
*P*
*P*                         C. THE ADDRESS OF THE SECOND PAGE (IF ANY)
*P*                         OF THE BUFFER
*P*
*P*                         D. THE ADDRESS OF THE SECOND PAGE (IF ANY)
*P*                         OF THE P-S LIST
*P*
*P*               ALL THESE ARE REAL ADDRESSES.
*P*
*P*               2)  IT IS CAPABLE OF POLLING CONTINUOUSLY DOWN (OR
*P*               AROUND) THE P-S LIST UNTIL A READ IS SUCCESSFUL OR
*P*               THE CALLER SPECIFIES HALT
*P*
*P*               3)  WHEN IT FINALLY EXITS AN I/O IT UPDATES THE
*P*               START AND CURRENT P-S INDICES BOTH IN THE 4 WORD
*P*               BUFFER AND IN THE P-S LIST
*P*
*P*               4)  WHILE ALL I/O TO THE TERMINAL IS DONE IN ASCII
*P*               (EVEN PARITY) V2IO TRANSLATES SUCH THAT THE CALLER
*P*               SENDS AND RECIEVES EBCDIC
*P*
*P*               5)  TO SAVE SYSTEM OVERHEAD V2IO AUTOMATICALLY WAITS
*P*               BETWEEN PASSES DOWN THE P-S LIST WHEN POLLING.  THIS
*P*               IS DONE BY DOING A WRITE WITH SKIP THAT TAKES APPROX-
*P*               IMATELY 200MS.
*P*
*P*               V2IO IS ENTERED WITH A FUNCTION CODE OF EITHER ZERO
*P*               (READ) OR X'80' (WRITE) AND TRANSLATES THIS INTO
*P*               INTERNAL FUNCTION CODES AS APPROPRIATE.
*P*
*P*
         SYSTEM   SIG7FDP
*
*   REGISTER DEFINITIONS            :
*                                   :
R0       EQU      0                 :
R1       EQU      1                 :
R2       EQU      2                 :
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
SR1,R8   EQU      8
SR2,R9   EQU      9
SR3,R10  EQU      10
SR4,R11  EQU      11
D1,R12   EQU      12
D2,R13   EQU      13
D3,R14   EQU      14
D4,R15   EQU      15
*
         PAGE
*
*
*          REFS AND DEFS
*
*
         DEF      V2IO              HANDLER FRONTEND ENTRY POINT
         DEF      V2CU              HANDLER BACKEND ENTRY POINT
*
*
         REF      M7                MASK
         REF      M9                MASK
         REF      M8                MASK
         REF      M11               MASK
         REF      M16               MASK
         REF      M22               MASK
         REF      Y0008             AUTO BIT AND UNUSUAL END
         REF      Y02               DATA SET NOT READY IN TDV STATUS
*
         REF      TSTACK            TO PUSH AND PULL
*
         REF      IOQ4              I/O: CALLING F.C. 0=>READ, X'80'=>WRITE
*,*                                 X'40' = READ COMPLETE FLAG
         REF      IOQ5              I/O:  CURRENT FUNCTION CODE - USED TO
*,*                                 BRANCH BETWEEN TYPES OF I/O
         REF      IOQ8              INPUT: BUFFER ADDRESS (FIRST PAGE)
         REF      IOQ9              I/O: WHEN CALLED BYTE COUNT - USED TO
*,*                                 HOLD REMAINING BYTE COUNT
         REF      IOQ11             INPUT: RETRIES REMAINING - USED TO
*,*                                 DETERMINE LAST RETRY
         REF      IOQ12             TEMP: USED TO HOLD #WORDS OF P-S
*,*                                 LIST IN FIRST PAGE, PAGE # OF SECOND
*,*                                 PAGE OF P-S LIST - 16,16
         REF      IOQ13             INPUT: END-ACTION ADDR AND INFO - INFO
*,*                                 USED TO FIND 4 WORD BUFFER WITH
*,*                                 EXTRA INPUTS
         REF      DCT2              INPUT: CITX TO RESTORE R4
         REF      DCT3              INPUT: X'10 BIT SAYS I/O TIMED OUT
         REF      DCT6              I/O: IOQ INDEX IS SAVED HERE WHILE
*,*                                 USING R3
         REF      DCT7              INPUT: DA OF COMMAND LIST AREA
         REF      DCT13             INPUT: TDV STATUS USED TO COMPUTE
*,*                                 LENGTH OF MESSAGE INPUT AND CHECK
*,*                                 FOR LINE HANG-UPS
         REF      DCT12             INPUT: AIO STATUS USED TO CHECK
*,*                                 FOR LINE HANG-UPS
         REF      DCT17             I/O: USED TO CHANGE FOLLOWON F.C.
*
         REF      IOSCU             CALLED: TO EXIT THE POST HANDLER
         REF      IOSERCK           CALLED: TO CHECK FOR DEVICE ERRORS
         REF      COMLIST           CALLED: TO EXIT THE PRE-HANDLER TO
*,*                                 BUILD A COMMAND CHAIN
         REF      USECOM            CALLED: TO RETURN TO COMLIST (CURRENT
*,*                                 COMMAND TO BE USED) FROM SPECIAL
*,*                                 COMLIST ROUTINES
         REF      DELCOM            CALLED: TO RETURN TO COMLIST (CURRENT
*,*                                 COMMAND TO BE SKIPPED) FROM SPECIAL
*,*                                 COMLIST ROUTINES
         REF      TDV760X           CALLED: TO GET TDV STATUS AND BE
*,*                                 SURE DCT13 IS OK FOR FECP
*
*
*
*
*          RANDOM  DEFINITIONS
*
*        POLLING LIST FLAGS
*
HALT     EQU      X'40000'
AUTO     EQU      Y0008
CLOSED   EQU      X'10000'
         PAGE
*
*        :DOT TABLE FOR COMLIST
*
:DOT     CNAME
         PROC
LF       EQU      %-DOT
         GEN,8,8,8,8 BA(AF(1))-BA(DOT),AF(2),AF(3),AF(4)
         PEND
*
*  PST:SET BUILDS THE POST ENTRY VECTOR TABLE
* AF(1) IS THE POST ENTRY POINT FOR THIS FC
*
PST:SET  CNAME
*
DOT%X    SET      1
         PROC
         ERROR,15,(AF(1)-BASE:)>255 'PST TOO FAR FROM BASE:'
POST%V(DOT%X)  SET   AF(1)-BASE:
DOT%X    SET      DOT%X+1
         PEND
*
*
         PAGE
*
DOT      SET      %
V2:DOT   EQU      DOT
*
         :DOT     0,0,0,0
         PST:SET  BASE:+EOT                 GENERATES 2ND BYTE OF EOTM
*
V2RD:DOT :DOT     WP%,1,V2RD:DOT,V2RD:DOT --POL AND READ
         PST:SET  CHK%RD                 *
V2SL:DOT :DOT     SL%,1,V2SL:DOT,V2WT:DOT --SELECT AND READ ACK
         PST:SET  CHK%AK                 *
V2WT:DOT :DOT     WT%,1,V2WT:DOT,V2ET:DOT --WRITE AND READ ACK
         PST:SET  CHK%AK                 *
V2ET:DOT :DOT     ET%,1,V2ET:DOT,V2RD:DOT --SEND EOT (ACK-EOT)
         PST:SET  NXT%OP                 *
V2NK:DOT :DOT     NK%,1,V2NK:DOT,V2RD:DOT --SEND NAK AND READ
         PST:SET  CHK%RD                 *
V2WG:DOT :DOT     WG%,1,V2RD:DOT,V2RD:DOT --WRITE TIMING DELAY ZEROS
         PST:SET  FOLLOWON
DOT%X    SET      DOT%X-1
         PAGE
:CLST    CNAME
         PROC
LF       GEN,8    DA(AF(1))-DA(DOT)
         PEND
*
WP%      :CLST    WHCOM             WRT POL HDR FROM CL
RH%      :CLST    RHCOM             RD RSP HDR INTO CL
RX%      :CLST    RDCOM             RD DATA
         :CLST    RDCOM             RD DATA
         :CLST    RSCOM             RD TRAILER INTO CL AK BUF
*                                   -
SL%      :CLST    WHCOM             WRT SEL HDR FROM CL
         :CLST    RSCOM             RD RSP INTO CL AK BUF
*                                   -
WT%      :CLST    STXCOM            WRT STX
WX%      :CLST    WTXTCOM           WRT DATA
         :CLST    WTXTCOM           WRT DATA
         :CLST    ETXCOM            WRT ETX
         :CLST    RSCOM             RD RSP INTO CL AK BFR
*                                   -
ET%      :CLST    ETCOM             WRT ACK-EOT
*                                   -
NK%      :CLST    NKCOM             WRT NAK
         :CLST    RHCOM             *
         :CLST    RDCOM             RD AS IN WP%
         :CLST    RDCOM             *
         :CLST    RSCOM             *
*                                   -
WG%      :CLST    WGCOM             WRT 200MS OF ZERO (SKIP)
         PAGE
*
*
*       COMMAND LIST DEFINITIONS
*
*
AKB%DSP  EQU      43
STRT%DSP EQU      40
AKB%IND  EQU      10
CM1%BBC  EQU      14
CM2%BBC  EQU      16
CNT%RD   EQU      CM1%BBC-(RD%ST**1)
CNT%WRT  EQU      CM1%BBC-(WT%ST**1)
HDR%DSP  EQU      44
HDR%IND  EQU      AKB%IND
SVSTF    EQU      12
RD%ST    EQU      BA(RX%)-BA(WP%)
RD%HD    EQU      BA(RH%)-BA(WP%)
WT%ST    EQU      BA(WX%)-BA(WT%)
*
*THE COMMAND LIST AREA IS BUILT AS FOLLOWS:
*
*0 FIVE DOUBLEWORDS FOR COMMANDS
*
*10 HEADER BUFFER,0,ACK BUFFER (16,8,8)
*
*11 POLLING OR SELECTION HEADER (3 BYTES)
*
*12 P-S LIST ADDRESS
*
*13 TEMP WORD 1 OF P-S LIST
*
*14 TWO DOUBLEWORDS CONTAINING BUFF AND
* BYTE COUNT FOR DATA XFER COMMANDS - IF ONLY ONE
* COMMAND BUFFER OF SECOND IS ZERO
         PAGE
:CDW     CNAME
         PROC
LF       EQU      WA(%)
         DO       AF(2)=4
         DATA,1   CF(2)
         DATA,3   WA(AF(1))
         ELSE
         DATA,1   CF(2)
         DATA,3   BA(AF(1))
         FIN
         GEN,8,8,8,8    CF(3),X'80',AF(2),AF(3)
         PEND
*
         BOUND    8
*
*
*
WRT      EQU      1
RD       EQU      2
ENDF     EQU      X'1E'             NO CHAINS
DCF      EQU      X'9E'             DATA CHAIN
CCF      EQU      X'2E'             COMMAND CHAIN
SKF      EQU      X'1F'             SKIP
*
*
WHCOM    :CDW,WRT,CCF  V2%SPC1,4,3
STXCOM   :CDW,WRT,DCF     STXM,0,1
ETXCOM   :CDW,WRT,CCF     ETXM,0,1
RHCOM    :CDW,RD,DCF      V2%SPC4,4,2
RDCOM    :CDW,RD,DCF    V2%SPC2,4,0
WTXTCOM  :CDW,WRT,DCF     V2%SPC25,4,0
RSCOM    :CDW,RD,ENDF     V2%SPC3,4,1
ETCOM    :CDW,WRT,ENDF       EOTM,0,2
NKCOM    :CDW,WRT,CCF        NAKM,0,1
WGCOM    :CDW,WRT,SKF   V2IO,0,100
*
*
V2%SPC1  EQU      %
         LI,R5    HDR%DSP
V2%SPC01 EQU      %
         LH,R12   DCT7,R1
         SLS,R12  3                 INSERT CL ADDR INTO COMMAND
         AW,R12   R5
V2%SPC   EQU      %
         OR,R8    R12
         B        USECOM
V2%SPC2  EQU      %
         LI,R12   CNT%RD
V2%SPC28 AD,R8    *R12,R7           INSERT BUF AND BC INTO DATA
         CW,R8    M22               XFER COM - IF BUF=0 DELETE
         BAZ      DELCOM
         B        USECOM
V2%SPC25 LI,R12   CNT%WRT
         B        V2%SPC28
V2%SPC3  EQU      %
         LI,R5    AKB%DSP
         B        V2%SPC01
V2%SPC4  EQU      %
         LI,R5    STRT%DSP
         B        V2%SPC01
         PAGE
ACK      EQU      X'06'             ACKNOWLEDGE
EOT      EQU      X'84'             END OF TRANSMISSION
SOH      EQU      X'81'             START OF HEADER
STX      EQU      X'82'             START OF TEXT
ETX      EQU      X'03'             END OF TEXT
SYNC     EQU      X'96'             SYNC
NAK      EQU      X'95'             NEGATIVE ACKNOWLEDGE
DC4      EQU      X'14'             VISTA2 SELECT
ENQ      EQU      X'05'             VISTA2 POLL
*
*
*
STXM     DATA,1   STX
NAKM     DATA,1   NAK
ETXM     DATA,1   ETX
EOTM     DATA,1   ACK
* ALTHOUGH IT SI CALLED EOTM THE ABOVE MESSAGE
*ACTUALLY SENDS ACK AND EOT - ON A READ
*RESPONSE ONLY THE ACK IS NOTICED AND ON A
*WRITE ONLY THE EOT -- NEAT HUH?
         PAGE
*
*POST ENTRY DISPLACEMENTS FROM BASE:
*
PST%VEC  EQU      %
PV       DO       DOT%X
*THE 84 BELOW IS 2ND BYTE OF EOTM GENNED BY PST:SET
         DATA,1   POST%V(PV)
         FIN
         BOUND    4
         PAGE
*
*
V2IO     EQU      %                 HANDLER FRONT END
         LB,R5    IOQ5,R3           -
         AND,R5   M7                IF THIS IS THE FIRST ENTRY
         BEZ      SET%UP            THIS IOQ GO TO SET%UP OTHERWISE
PRE%XIT  EQU      %                 OFF TO COMLIST
         STB,R5   IOQ5,R3
         LI,R10   V2:DOT
         B        COMLIST           IOQ4 -- 0=RD 80=WRT
         SPACE    5
V2CU     EQU      %                 HANDLER BACKEND
         LB,R5    DCT3,R1           -
         CI,R5    X'10'             IF WE TIMED OUT GO RETRY
         BANZ     V2%TO             IF WE GOT UNUSUAL END TREAT
         LW,R5    DCT12,R1          IT AS THOUGH WE TIMED OUT
         CW,R5    Y0008             -
         BANZ     V2%TO             IF DS NOT RDY DO SAME
         BAL,R6   TDV760X           TDV760X FIXES RBC IF FECP
         CW,R9    Y02               -
         BANZ     V2%TO             OTHERWISE GET CL DA IN 5
         BAL,R9   IOSERCK           P-S LIST WA IN 6, TEMP P-S
         B        PST%XIT           WORD ONE IN 7, AND CL BUFS
         LB,R5    IOQ5,R3           INTO 10 AND 11-- THEN OFF TO
         LB,R12   PST%VEC,R5        POST ENTRY OF FC.
         AI,R12   BASE:
         LH,R5    DCT7,R1
         LD,R6    SVSTF,R5
         LD,R10   AKB%IND,R5
         B        *R12
         PAGE
BASE:    EQU      %
CHK%RD   EQU      %                 CHECK RESPONSE TO READ
         LB,R12   R10               *
         CI,R12   EOT               IF EOT GO DO NEXT GUY
         BE       NXT%OP            *
         LD,R12   DCT13,R1          ELSE CALCULATE HANDY ADDR
         AI,R5    RD%HD             OF LAST COM EXECED
         SW,R12   R5                IF ONLY ONE - EOT GOT
         BEZ      BD%EOT            ZAPPED
         LI,R6    V2NK:DOT**8+V2ET:DOT HE HEARD US -
         STH,R6   DCT17,R1          NO NEED TO POL AGAIN
         LH,R10   R10               *
         AI,R10   EOT**8-STX**8     CHECK HIS HEADER AGAINST
         CH,R10   R11               OURS TO SEE IF RITE GUY
         BNE      NAKOUT1           *
         XW,R12   R5                *
         LI,R10   0                 SET REGS FOR TRANS
         LI,R6    0                 *
         SLS,12   1                 *
         LD,R8    *R12,R5           ON FIRST COMMAND S
         SW,R9    R13               SUBTRACT OFF RBC AND
         BAL,R0   TRAN%IN           CHECK FOR ETX
         AI,R7    -1                COMS ARE PROCSSED LAST
         LB,R7    0,R7              TO FIRST
         CI,R7    ETX
         BNE      NAKOUT3
TRIN%GO  EQU      %                 PROC COMS NOT 1ST
         BDR,R5   TRN%IN1           *
         LH,R11   IOQ9,R3           AT SUCCESSFUL END
         AI,R10   -1                CALC REAL RBC AND
         SW,R11   R10               SAVE IN IOQ9 --
         STH,R11  IOQ9,R3           SET READ DONE FLAG
         LI,R12   X'40'             AND GO TELL HIM
         STB,R12  IOQ4,R3           WE HEARD
         B        FOLLOWON
TRN%IN1  EQU      %                 SET RETURN AND NEXT
         LI,R0    TRIN%GO           COMMAND
         LD,R8    *R12,R5           *
TRAN%IN  EQU      %                 TRANSLATE INPUT AND
         AND,R9   M16               CHECK PARITY
         AW,R10   R9                *
         XW,R8    R9                R8 AND R9 HAVE I/O
         LW,R7    R9                COMMAND
         LI,R11   255
TRN%IN2  EQU      %
         CI,R8    255
         BGE      %+2
         LW,R11   R8
         STB,R11  R9
         STB,R11  R7
         TBS,R6   BA(V2IN)
         LCI      1
*THIS INSTRUCTION CHECKS PARITY -- HOW IT DOES IT IS
*LEFT AS AN EXERCISE FOR THE READER -- SMK
         EBS,R8   0
         BCR,1    NAKOUT2
         AND,R8   M16
         AI,R8    -255
         BGZ      TRN%IN2
         B        *R0
CHK%AK   EQU      %                 CHK RESP ON SEL OR WRT
         AND,R10  M8                *
         CI,R10   ACK               IF ACK CONTINUE
         BE       FOLLOWON          *
         CI,R10   EOT               IF EOT TEL USER NO GO
         BNE      NAKIN             *
         LI,R12   9                 OTHERWISE IT'S NAK RETRY
         B        SET%STI
NXT%OP   EQU      %                 MOVE DOWN P-S LIST
         LI,R12   X'B'              *
         LC       IOQ4,R3           IF WE DID A SUCCESSFUL
         BCS,8    SET%STI           RD OR WRT WERE DONE
         BCS,4    ST%STI1           *
         LI,R12   3                 IF IT WAS A NO RESPONSE RD
         LW,R10   0,R6              AND HALT IS SPECIFIED OR
         CI,R10   HALT              AUTO ISNT WE TELL THE USER
         BANZ     SET%STI           *
         CW,R10   AUTO              OTHERWISE WE ADVANCE TO THE
         BAZ      SET%STI           NEXT P-S ENTRY
         LB,R13   R7
         BAL,R0   G%PADR
         LB,R13   *R13
         LI,R4    2                 IF THIS ISNT WHERE WE
         CB,R13   R7,R4             STARTED WE FOLLOW-ON
         BNE      N%OP1             TO READ THIS GUY
         LI,R12   X'F'              *
         CI,R10   CLOSED            IF CLOSED LIST WERE DONE
         BAZ      SET%STI           OTHERWISE WRITE TIMING
         LI,R10   V2WG:DOT          DELAY BEFORE GOING ON TO
         STH,R10  DCT17,R1          NEXT GUY
N%OP1    EQU      %                 *
         STB,R13  R7                SAVE PTRS - SET ADDR
         STD,R6   SVSTF,R5          AND CONTINUE...
         BAL,R9   SET%ADR
FOLLOWON EQU      %                 SET FOLLOWON - INTER-OP
         LI,R12   X'6000'           *
PST%XIT  EQU      %                 RESTORE R4 AND EXIT TO IOQ
         LB,R4    DCT2,R1           WITH THE FINAL TYC
         B        IOSCU
SET%UP   EQU      %                 TRANSLATE INPUT INFO INTO
         STB,R3   DCT6,R1           USABLE FORM
         LH,R5    DCT7,R1           *
         LD,R6    IOQ13,R3          THE END ACTION INFO OF ALL
         AND,R7   M16
         LW,R6    0,R7              IO CALLS IS A POINTER TO
         LW,R10   3,R7              A FOUR WORD CONTEXT BLOCK
         LH,R12   R10               LOOKING AS FOLLOWS:
         BEZ      SET%BGPL          *
         LCW,R13  0,R7              1 START P-S INDEX,RA(P-S) 8,24
         AND,R13  M9                2 - IGNORED
         BNEZ     %+2               3 - IGNORED
SET%BGPL LI,R13   511               4 PG#2(P-S),PG#2(BUF) 16,16
         AI,R13   -1                *
         STH,R13  R12               IOQ12 IS SET TO BE:
         STW,R12  IOQ12,R3          *
         LI,R13   0                 SZ(P-S) IN PG1-1,PG#2(P-S) 16,16
         BAL,R0   G%PADR            *
         LW,R7    *R13              THE STARTING P-S INDEX IS
         LC       IOQ4,R3           OBTAINED FROM CXT OR P-S AND
         LI,R3    2                 MADE THE ST AND CUR INDEX IN
         BCR,8    %+2               THE TEMP P-S WD1 AND
         LI,R3    3                 IT AND THE P-S ADDR ARE STORED
         LB,R13   R6                IN THE CL
         BNEZ     %+2               *
         LB,R13   R7,R3             THE HEADER FOR THE POL OR
         STB,R13  R7,R3             SEL OF THE STARTING GUY IS
         AI,R3    -2                SET IN THE CL
         STB,R13  R7,R3             *
         STD,R6   SVSTF,R5          THE BUF AND BC FOR 1 OR
         LB,R3    DCT6,R1           2 DATA XFER COMMANDS IS
         BAL,R9   SET%ADR           CALCULATED AND STORED IN
SET%BUF  EQU      %                 THE CL
         LW,R8    IOQ8,R3
         LH,R9    IOQ9,R3
         LW,R11   IOQ8,R3
         AND,R10  M16
         BEZ      STR%CL
         SLS,R10  11
         AND,R11  M11
         AH,R11   IOQ9,R3
         AI,R11   -X'800'
         SW,R9    R11
STR%CL   EQU      %
         STD,R8   CM1%BBC,R5
         STD,R10  CM2%BBC,R5
         LI,R5    V2RD:DOT          IF THIS IS A READ THE
         LC       IOQ4,R3           CALLING FC IS CHANGED TO
         BCR,8    PRE%XIT           READ AND WE GO TO COMLIST
         PSW,R1   TSTACK            *
         LW,R1    R8                IF IT'S A WRITE THE BUFFER
         BAL,R12  TR%OUT            IS TRANSLATED TO ASCII AND
         LW,R1    R10               WE GO SAYING WRITE
         BEZ      %+3
         LW,R9    R11
         BAL,R12  TR%OUT
         PLW,R1   TSTACK
         LI,R5    V2SL:DOT
         B        PRE%XIT
G%PADR   EQU      %                 GET P-S LIST ADDRESS INTO R13
         AI,R13   1                 GIVEN INDEX INTO LIST
         LW,R8    IOQ12,R3          IF INDEX IS IN FIRST PAGE
         CH,R13   R8                WE SIMPLY ADD DISP IN R6
         BG       %+3               *
         AW,R13   R6                IF NOT WE GET THE DISP INTO
         B        *R0               SECOND PAGE AND ADD IN PAGE
         SH,R13   R8                ADDR FROM IOQ12
         AI,R13   -1
         AND,R8   M16
         SLS,R8   9
         AW,R13   R8
         B        *R0
TR%OUT   EQU      %                 TRANSLATE TO ASCII FOR OUTPUT
         LI,R13   252               *
         CI,R9    252               BA(BUF) IN R1 BC IN R9
         BGE      %+2               *
         LW,R13   R9                252 IS TO MAKE TBS WORD BY WORD
         STB,R13  R1
         TBS,0    BA(V2OUT)
         AI,R9    -252
         BGZ      TR%OUT
         B        *R12
SET%ADR  EQU      %                 SET POL OR SEL HDR IN CL
         BAL,R0   G%PADR            *
         LW,R13   *R13              INDEX OF P-S ENTRY IN R13
         SLS,R13  16                *
         LC       IOQ4,R3           RESULT IS EOT,ADR,(DC4 OR ENQ)
         BCR,8    %+2               ** 8,8,8  LFT ADJ IN R13
         AI,R13   DC4**8-ENQ**8
         AI,R13   ENQ**8            STORED INTO CL
         LI,R8    EOT
         STB,R8   R13
         STD,R12  HDR%IND,R5
         B        *R9
ST%STI1  LI,R12   1                 INPUT SUCCESS ENTRY POINT
         LH,R11   IOQ9,R3           *
         B        %+2               TYC=1 RBC TO R11 AS SAVED
SET%STI  EQU      %                 *
         LI,R11   0                 SET STARTING INDEX IN P-S LIST
         LI,R4    0                 *
         LC       IOQ4,R3           THE APPROPRIATE CURRENT INDEX IS
         BCR,8    %+2               PICKED UP AND STORED INTO THE
         LI,R4    1                 CONTEXT BUFFER
         LB,R13   R7,R4             THEN IT IS USED TO FIND THE NEXT
         LD,R8    IOQ13,R3          INDEX WHICH IS STORED INTO THE
         AND,R9   M16
         STB,R13  *R9               APPROPRIATE START INDEX LOC.
         BAL,R0   G%PADR            THE CORRECTED P-S WORD1 NOW
         LB,R13   *R13,R4           IN R7 IS STORED BACK INTO THE
         AI,R4    2                 P-S LIST AND WE'RE READY TO
         STB,R13  R7,R4             EXIT TO THE USER
         LI,R13   0
         BAL,R0   G%PADR
         STW,R7   *R13
         B        PST%XIT
V2%TO    EQU      %                 GO TO APPROPRIATE TIMOUT ROUTINE
         LC       IOQ4,R3
         BCS,8    TO%WT
         B        TO%RD
BD%EOT   MTB,2    R5                *
NAKIN    MTB,5    R5                *
TO%WT    MTB,1    R5                *
NAKOUT1  MTB,1    R5                THE TOP BYTE OF R5 BECOMES TYC
NAKOUT2  MTB,1    R5                *
NAKOUT3  MTB,2    R5                *
TO%RD    MTB,2    R5                *
         LB,R12   R5                TYC TO 12 AND RESTORE REGS
         LH,R5    DCT7,R1           *
         LD,R6    SVSTF,R5          IF THE LINE HAS DISCONNECTED
         LD,R8    DCT13,R1          (DATA SET NOT READY IN TDV
         CW,R9    Y02               STATUS) OR WE GOT UNUSUAL END
         BANZ     SET%STI           IN THE AIO STATUS HE DOESNT
         LW,R8    DCT12,R1          GET ANY MORE RETRIES
         CW,R8    Y0008             -
         BANZ     SET%STI           IF LAST TRY GET OUT VIA SET%STI
         MTB,-1   IOQ11,R3          OTHERWISE SET RETRY BIT IN R12
         BEZ      SET%STI           AND LET IOSCU DECREMENT IOQ11
         MTB,1    IOQ11,R3
         AI,R12   X'C000'
         LI,R13   0                 DONT PRINT ANY MESSAGES
         B        PST%XIT
         PAGE
*
*VARIOUS AND SUNDRY ASCII CONSTANTS
*
BP       EQU      X'22'             BAD PARITY
BEL      EQU      X'87'
BS       EQU      X'88'
HT       EQU      9
LF       EQU      10
VT       EQU      X'8B'
FF       EQU      12
CR       EQU      X'8D'
SO       EQU      X'8E'
SI       EQU      15
DLE      EQU      X'90'
DC1      EQU      X'11'
DC2      EQU      X'12'
DC3      EQU      X'93'
ETB      EQU      X'17'
CAN      EQU      X'18'
EM       EQU      X'99'
SUB      EQU      X'9A'
ESC      EQU      X'1B'
FS       EQU      X'9C'
GS       EQU      X'1D'
RS       EQU      X'1E'
US       EQU      X'9F'
SP       EQU      X'A0'
BANG     EQU      X'21'
A        EQU      X'41'
B        EQU      X'42'
C        EQU      X'C3'
D        EQU      X'44'
E        EQU      X'C5'
F        EQU      X'C6'
G        EQU      X'47'
H        EQU      X'48'
I        EQU      X'C9'
J        EQU      X'CA'
K        EQU      X'4B'
L        EQU      X'CC'
M        EQU      X'4D'
N        EQU      X'4E'
O        EQU      X'CF'
P        EQU      X'50'
Q        EQU      X'D1'
C:R      EQU      X'D2'
C:S      EQU      X'53'
T        EQU      X'D4'
U        EQU      X'55'
V        EQU      X'56'
W        EQU      X'D7'
X        EQU      X'D8'
Y        EQU      X'59'
Z        EQU      X'5A'
DEL      EQU      X'FF'
         PAGE
*
* EBCDIC TO ASCII EVEN PARITY OUTPUT TRANSLATE TABLE
*
*CARE IS TAKEN TO PREVENT TRANLATION TO LINE CONTROL CHARS
*
V2OUT    EQU      %
*
         DATA,1   0,0,0,0,0,HT,0,BEL
         DATA,1   BS,0,0,VT,FF,CR,SO,SI
         DATA,1   DLE,DC1,DC2,DC3,0,LF,0,ETB
         DATA,1   CAN,EM,SUB,ESC,FS,GS,RS,US
         DO1      4
         DATA,8   0                 X'20'-X'3F' ARE INVALID
         DATA,1   SP,0,0,0,0,0,0,0,0,0,X'60',X'2E'
         DATA,1   X'3C',X'28',X'2B'
         DATA,1   X'FC'
         DATA,1   X'A6',0,0,0,0,0,0,0,0,0,BANG
         DATA,1   X'24',X'AA',X'A9',X'BB',X'7E'
         DATA,1   X'2D',X'AF',0,0,0,0
         DATA,1   0,0,0,0,X'DE',X'AC',X'A5'
         DATA,1   X'5F',X'BE',X'3F'
         DATA,1   0,0,0,0,0,0,0,0,0,0
         DATA,1   X'3A',X'A3',X'C0',X'27'
         DATA,1   X'BD',X'22',X'00'
         DATA,1   X'E1',X'E2',X'63',X'E4'
         DATA,1   X'65',X'66',X'E7',X'E8'
         DATA,1   X'69',0,0,0,0,0,0,0
         DATA,1   X'6A',X'EB',X'6C',X'ED'
         DATA,1   X'EE',X'6F',X'F0',X'71',X'72'
         DATA,1   0,0,0,0,0,0,0,0
         DATA,1   X'F3',X'74',X'F5',X'F6',X'77'
         DATA,1   X'78',X'F9',X'FA'
         DATA,1   0,0,0,0,0,0
         DATA,1   0,X'5C',X'7B',X'7D',X'DB',X'DD'
         DATA,1   0,0,0,0,0,0,0,0,0,0
         DATA,1   0,A,B,C,D,E,F,G,H,I
         DATA,1   0,0,0,0,0,0
         DATA,1   0,J,K,L,M,N,O,P,Q,C:R
         DATA,1   0,0,0,0,0,0
         DATA,1   0,0,C:S,T,U,V,W,X,Y,Z
         DATA,1   0,0,0,0,0,0
         DATA,1   X'30',X'B1',X'B2',X'33'
         DATA,1   X'B4',X'35',X'36',X'B7'
         DATA,1   X'B8',X'39',0,0,0,0,0,DEL
         PAGE
*
*ASCII TO EBCDIC INPUT TRANSLATION TABLE AND PARITY CHECK
*
*LINE CONTROL CHARACTERS TRANSLATE AS BAD PARITY
*
V2IN     EQU      %
*
         DATA,1   0,BP,BP,ETX
         DATA,1   BP,BP,BP,BP
         DATA,1   BP,5,X'15',BP
         DATA,1   FF,BP,BP,SI
*
         DATA,1   BP,DC1,DC2,BP
         DATA,1   BP,BP,BP,ETB
         DATA,1   CAN,BP,BP,ESC
         DATA,1   BP,GS,RS,BP
*
         DATA,1   BP,X'5A',X'7F',BP
         DATA,1   X'5B',BP,BP,X'7D'
         DATA,1   '(',BP,BP,'+'
         DATA,1   BP,'-','.',BP
*
         DATA,1   '0',BP,BP,'3'
         DATA,1   BP,'5','6',BP
         DATA,1   BP,'9',':',BP
         DATA,1   '<',BP,BP,'?'
*
         DATA,1   BP,'A','B',BP
         DATA,1   'D',BP,BP,'G'
         DATA,1   'H',BP,BP,'K'
         DATA,1   BP,'M','N',BP
*
         DATA,1   'P',BP,BP,'S'
         DATA,1   BP,'U','V',BP
         DATA,1   BP,'Y','Z',BP
         DATA,1   X'B1',BP,BP,X'6D'
*
         DATA,1   X'4A',BP,BP,X'83'
         DATA,1   BP,X'85',X'86',BP
         DATA,1   BP,X'89',X'91',BP
         DATA,1   X'93',BP,BP,X'96'
*
         DATA,1   BP,X'98',X'99',BP
         DATA,1   X'A3',BP,BP,X'A6'
         DATA,1   X'A7',BP,BP,X'B2'
         DATA,1   BP,X'B3',X'5F',BP
*
         DATA,1   BP,BP,2,BP
         DATA,1   BP,BP,BP,7
         DATA,1   8,BP,BP,11
         DATA,1   BP,13,14,BP
*
         DATA,1   16,BP,BP,19
         DATA,1   BP,BP,BP,BP
         DATA,1   BP,X'19',X'1A',BP
         DATA,1   X'1C',BP,BP,X'1F'
*
         DATA,1   ' ',BP,BP,'#'
         DATA,1   BP,'%','&',BP
         DATA,1   BP,')','*',BP
         DATA,1   ',',BP,BP,'/'
*
         DATA,1   BP,'1','2',BP
         DATA,1   '4',BP,BP,'7'
         DATA,1   '8',BP,BP,';'
         DATA,1   BP,'=','>',BP
*
         DATA,1   '@',BP,BP,'C'
         DATA,1   BP,'E','F',BP
         DATA,1   BP,'I','J',BP
         DATA,1   'L',BP,BP,'O'
*
         DATA,1   BP,'Q','R',BP
         DATA,1   'T',BP,BP,'W'
         DATA,1   'X',BP,BP,X'B4'
         DATA,1   BP,X'B5',X'6A',BP
*
         DATA,1   BP,X'81',X'82',BP
         DATA,1   X'84',BP,BP,X'87'
         DATA,1   X'88',BP,BP,X'92'
         DATA,1   BP,X'94',X'95',BP
*
         DATA,1   X'97',BP,BP,X'A2'
         DATA,1   BP,X'A4',X'A5',BP
         DATA,1   BP,X'A8',X'A9',BP
         DATA,1   X'4F',BP,BP,X'FF'
*
         END

