/PAPER-TAPE OUTPUT (ASCII)
 .LOC 17000
    PASIZE
    .SIXBT 'PP'
    300002                  /OUTPUT
PB  10                      /PARITY BIT
    .SIXBT 'PPB'
PASC
    SNL; JMP PA2          /CLOSE ->
    SAD .NL; SKP; JMP PA1 /NOT NL ->
    LAC CR; JMS* PASC-1
    LAC LF
PA1 DAC J
    RCR
    SZL!RCR; CML; SZA; JMP .-3
    LAC J; SZL!STL; XOR PB
PA2 JMS* PASC-1
    JMP* PASC
CR  215;LF 12
J
PASIZE=.

 .LOC 17000
    .SIZE
    .SIXBT 'PPB'
    300002
NUL 13                      /RUNOUT
PUNCH
    DAC K
    SNL!CLC; JMP P5         /CLOSE ->
    SAD LIM; SKP!CLA; JMP P1 /FILE OPEN ->
    JMS .BU; DAC BS         /GET BUFFER
    DAC A1; DAC A2          /SET POINTERS
    LAW -400; JMS RUN       /HEADER (SETTING LIM)
P1  LAC K; JMS OUT
    STL
    JMP* PUNCH
P5  SAD LIM; JMP* PUNCH     /FILE NOT OPEN =>
    JMS RUN                 /TRAILER (SETTING LIM)
    LAC BS; JMS .BU         /RELEASE BUFF
    CLL!CLC
    JMP* PUNCH
RUN
    DAC LIM                 /SET LAW INSTRN
    LAW -300; DAC L
    LAC NUL; JMS OUT        /RUNOUT
    ISZ L; JMP .-3
    JMP* RUN
OUT
    DAC* A1; ISZ A1
    LAW -400; TAD A1        /WRAP ROUND
    SAD BS; DAC A1          /IF NECESSARY
    ISZ CHARS
    LAW -MIN; TAD CHARS     /CHARS >= MINIMUM?
    SPA; JMP O3             /NO ->
    LAC IND                 /HANDLER ACTIVE?
    SMA!SZA; JMP O3         /YES ->
O1  SMA; JMP O2             /OFF ->
    LAC LITPP               /ERROR
    GUARD; JMP .MH          /REPORT
O2  GUARD; JMP H            /ACTIVATE HANDLER
O3  GUARD
LIM LAW -1; TAD CHARS       /CHARS >= LIMIT
    RAL; LAC IND            /& HANDLER ACTIVE?
    SNL!SMA!SZA; WAIT       /YES => WAIT
    ION
    SNL; JMP O1             /-> ACTIVATE
    JMP* OUT
/HANDLER
H   ACCEPT
    DZM IND; ISZ IND        /HANDLER ACTIVE
H1  IORS; AND (400          /OUT-OF-TAPE FLAG
    SZA!CLC; JMP H2         /SET ->
    TAD CHARS; DAC CHARS    /REDUCE CHARS
    LAC* A2; PSA            /PUNCH CHAR
    JMS .PP                 /WAIT FOR DEVICE
    PSF; JMP .PP+3          /NOT PUNCH =>
    ISZ A2
    LAW -400; TAD A2        /WRAP ROUND
    SAD BS; DAC A2          /IF NECESSARY
    LAC CHARS               /BUFF EMPTY?
    SZA; JMP H1             /NO ->
H2  DAC IND; PCF
    JMP .PP+2               /=> SYSTEM
LITPP .SIXBT 'PP'
BS;IND;CHARS;A1;A2;K;L
GUARD=JMS 3;WAIT=JMP 2;ACCEPT=ISZ 3
.BU=16000;.MH=16010;.PP=16020;.NL=16030
MIN=200;PSA=700204;PSF=700201;PCF=700202
 .END
