/TELETYPE AND BATCH
/TELETYPE INPUT
 .LOC 17000
    TISIZE
    .SIXBT 'TT'
    100001                  /TT INPUT
    .SIXBT 'N'
TI
    SAD LM1; JMP TI1        /CLOSE ->
    GUARD; JMP .KH          /CALL HANDLER
    SNA!STL; JMP .-3
    SAD L4; SKP!CLL         /CONTROL+D ->
    JMP* TI
TI1 LAC TI-1                /CONCATENATED FILE
    JMP* TI
L4  4;LM1 -1
TISIZE=.

/TELETYPE OUTPUT
 .LOC 17000
    TOSIZE
    .SIXBT 'TT'
    100002                  /TT OUTPUT
TO
    SNL; JMP* TO            /CLOSE =>
    GUARD; JMP .TH          /CALL HANDLER
    JMP* TO
TOSIZE=.

/BATCH PRE-PROCESSOR
 .LOC 17000
    BASIZE
    .SIXBT 'B'
    000001                  /INPUT
    .SIXBT 'N'
BI
    SPA; JMP B5             /CLOSE ->
    JMS GET
    JMP* BI
B5  LAC K                   /(PSEUDO) EOF?
    SPA!SNA!CLL!CLC; JMP* BI /YES =>
    JMS GET                 /SKIP
    JMP B5
GET
    LAC K
    SPA!CLL; JMP* GET
    SAD .NL; JMP G1         /START OF LINE ->
    CLL!CLA; JMS* BI-1      /CALL ATTACHED FILE
    JMP G2
G1  CLL!CLA; JMS* BI-1      /CALL ATTACHED FILE
    SAD L76; CLL!CLA        /PSEUDO-EOF FOR '>'
G2  DAC K
    JMP* GET
K   0;L76 76
BASIZE=.

/MONITOR INPUT
 .LOC 17000
    MISIZE
    .SIXBT 'M'
    000001                  /INPUT
    .SIXBT 'N'
MI
    JMS* MI-1               /CALL ATTACHED FILE
    DAC MIK
    SZL; JMS* .CS+1         /SEND TO REPORT STREAM
    LAC MIK
    JMP* MI
MIK
MISIZE=.

/MONITOR OUTPUT
 .LOC 17000
    MOSIZE
    .SIXBT 'M'
    000002                  /OUTPUT
    .SIXBT 'N'
MO
    DAC MOK
    JMS* MO-1               /CALL ATTACHED FILE
    SNL; JMP* MO            /CLOSE =>
    LAC MOK; JMS* .CS+1     /SEND TO REPORT STREAM
    JMP* MO
MOK
MOSIZE=.

/TELETYPE (EXEC)
 .LOC 17000
    .SIZE
    .SIXBT 'TTX'
    100002
TXO
    SNL; JMP* TXO           /CLOSE =>
    DAC CHAR
    GUARD
    LAC .KI; SAD .KL; WAIT  /ENSURE TP IDLE
    LAC POS; SNA            /IF FIRST
    LAC .KE; DAC POS        /SET POS
    LAC .KI
    SAD .TM; LAC .TS        /WRAP ROUND?
    TAD (1
    SAD .KE; JMP X8         /BUFF FULL ->
    DAC .KI
    DAC .TE; DAC .TI        /RESET TP POINTERS
X1  DAC YWL                 /DEST
    TAD (-1
    SAD .TS; LAC .TM        /HERE WE GO ROUND
    DAC XWL                 /SOURCE
    LAC* XWL; DAC* YWL      /MOVE DOWN ONE
    LAC XWL                 /ALL MOVED?
    SAD POS; SKP; JMP X1    /NO ->
    LAC YWL; DAC POS        /NEW POS
    LAC CHAR; DAC* POS      /STORE CHAR
    LAC POS                 /PRINT IT?
    SAD .KI; SKP; JMP X3    /NO ->
    LAC CHAR
    GUARD; JMP .TH
X3  ION; STL
    JMP* TXO
X8  ION
    CLL!CLC
    JMP* TXO
POS;CHAR;XWL;YWL

GUARD=JMS 3;WAIT=JMP 2
.KH=16000;.TH=16010;.CS=16020
.DH=16030;.MH=16040;.KL=16050
.KI=16060;.TM=16070;.TL=16100
.TS=16110;.TE=16120;.TI=16130
.KE=16140;.NL=16150
 .END
