/PAPER-TAPE INPUT /(ASCII)
 .LOC 17000
    RASIZE
    .SIXBT 'PR'
    300001
SP  5
MK  7
RUN 13
    .SIXBT 'PRB'
RASC
    SPA; JMP RA2+1
    LAC PEND; SMA; JMP RA3
RA1 DZM PEND
RA2 CLL!CLA; JMS* RASC-1
    SNL; JMP* RASC
    AND MK
    SAD RUN; JMP RA2
    SAD CR; JMP RA1
    SAD MK; JMP RA2
    SAD SP; JMP RA4
    SAD LF; LAC .NL
    TAD PEND
RA3 TAD LM400; DAC PEND
    SMA!STL; LAC SP
    AND L377
    JMP* RASC
RA4 LAC PEND; TAD L400
    DAC PEND
    JMP RA2
PEND -1
CR 15;LF 12
LM400 -400;L400 400;L377 377
RASIZE=.

/PAPER-TAPE INPUT (BINARY)
 .LOC 17000
    .SIZE
    .SIXBT 'PRB'
    300001                  /INPUT
    .SIXBT 'N'
READ
    SPA; JMP R5             /CLOSE ->
    LAC BS                  /FILE OPEN?
    SZA; JMP R2             /YES ->
    JMS .BU; DAC BS         /GET BUFFER
R1  DAC A1; DAC A2          /SET POINTERS
    LAC (400; DAC SLOTS     /NO OF SLOTS
    DZM IND
    JMS IN                  /-> GET CHAR
    LAC LITPR               /EOT
    GUARD; JMP .MH          /REPORT
    LAC BS
    JMP R1
R2  JMS IN                  /-> GET CHAR
R5  LAC IND                 /HANDLER ACTIVE?
    SMA!SZA; JMP .-2        /YES ->
    LAC BS                  /RELEASE BUFF
    SZA; JMS .BU            /IF FILE OPEN
    DZM BS                  /FILE CLOSED
    CLL; LAC READ-1         /CONCATENATED FILE
    JMP* READ
IN                          /EXIT FROM READ UNLESS EOT
I1  LAW -MIN; TAD SLOTS     /SLOTS >= MINIMUM?
    SMA; LAC IND            /& HANDLER OFF
    SZA; JMP I2             /NO ->
    GUARD; JMP H            /ACTIVATE HANDLER
I2  GUARD
    LAW -360; TAD SLOTS     /SLOTS >= 360
    RAL; LAC IND            /& HANDLER ACTIVE?
    SNL!SMA; WAIT           /YES => WAIT
    ION
    SNL; JMP* IN            /EOT ->
    LAW -400; TAD A1        /WRAP ROUND
    SAD BS; DAC A1          /IF NECESSARY
    LAC* A1
    ISZ A1; ISZ SLOTS
    STL
    JMP* READ
/HANDLER
H   ACCEPT
    ISZ IND                 /HANDLER ACTIVE
 .IFUND PDP7
H1  IORS; AND (1000         /NO-TAPE FLAG
    SZA!CLC; JMP H2         /SET ->
    RSA                     /SELECT READER
    JMS .PR                 /WAIT FOR DEVICE
    RSF; JMP .PR+3          /NOT PR =>
 .ENDC
 .IFDEF PDP7
H1  LAW -2; DAC 7
    RSA; CLON
    JMS .PR
    RSF; SKP!CLC; JMP .+4
    CLSF; JMP .PR+3
    JMP H2
 .ENDC
    RRB
    DAC* A2; ISZ A2
    LAW -400; TAD A2        /WRAP ROUND
    SAD BS; DAC A2          /IF NECESSARY
    CLC; TAD SLOTS          /REDUCE SLOTS
    DAC SLOTS
    SZA; JMP H1             /BUFF NOT FULL ->
H2  DAC IND
 .IFDEF PDP7
    CLOF
 .ENDC
    JMP .PR+2               /=> SYSTEM
LITPR .SIXBT 'PR'
BS;IND;SLOTS;A1;A2
GUARD=JMS 3;WAIT=JMP 2;ACCEPT=ISZ 3
.BU=16000;.MH=16010;.PR=16020;.NL=16030
MIN=200;RSA=700104;RSF=700101;RRB=700112
 .END
