/CARD INPUT
 .LOC 17000
    .SIZE
    .SIXBT 'CR'
    300001                  /INPUT
CAN 6                       /CANCEL CHAR
DC  11                      /DATA COLS
    .SIXBT 'N'
CI
    SPA; JMP C9             /CLOSE ->
    LAC K                   /NEW CARD?
    SMA; JMP C4             /NO ->
    LAC BS                  /FILE OPEN?
    SZA; JMP C1             /YES ->
    JMS .BU; DAC BS         /GET BUFFER
    DAC L1; DAC L2          /SET POINTERS
    LAC (3; DAC SLOTS       /SET CARD SLOTS
    DZM IND
C1  GUARD
    LAW -3; TAD SLOTS       /SLOTS = 3
    RAL; LAC IND            /& HANDLER ACTIVE?
    SNL!SMA!SZA; WAIT       /YES => WAIT
    ION
    SZL; JMP C3             /CARD AVAIL ->
    SMA; JMP C2             /NO ERR ->
    LAC LITCR
    GUARD; JMP .MH          /REPORT
C2  GUARD; JMP H            /ACTIVATE HANDLER
    JMP C1
C3  LAC* L1                 /ALL HOLES IN COL1?
    SAD (7777; JMP C9       /YES ->
    LAC L1; DAC A1
C4  LAC CTS; DAC I          /CONVERSION TABLE
    LAC* A1; DAC K
    SPA; JMP C7             /END OF CARD ->
    ISZ A1
    SAD (4006; LAC (2202
    SAD (0102; LAC (4202
C5  SAD* I; JMP C6
    ISZ I; JMP C5
C6  LAC CTS; CMA
    TAD (41; TAD I
    STL
    SAD (140;  CLL          /DATA ERROR
    JMP* CI
C7  ISZ SLOTS
    LAC L1; TAD (122        /ADVANCE LINE POINTER
    DAC L1; TAD (-366       /WRAP ROUND
    SAD BS; DAC L1          /IF NECESSARY
    LAC .NL; STL
    JMP* CI
C9  LAC IND                 /HANDLER ACTIVE?
    SMA!SZA; JMP .-2        /YES ->
    LAC BS                  /RELEASE BUFFER
    SZA; JMS .BU            /IF FILE OPEN
    DZM BS; DZM IND         /RESET INDICATORS
    CLL!CLC; DAC K
    LAC CI-1                /CONCATENATED FILE
    JMP* CI
/HANDLER
H   ACCEPT
    DZM IND; ISZ IND        /HANDLER ACTIVE
H1  CLC; TAD DC; CMA
    DAC WC                  /DATA COLUMNS (NEG)
    LAC L2; DAC A2
H2  CRSC                    /SELECT CARD
H3  JMS .CR                 /WAIT FOR DEVICE
    CRSI; JMP .CR+3         /NOT CR =>
    CROC
    SPA!RTR; JMP H9         /ERROR ->
    SZL; JMP H8             /END OF CARD ->
    AND (7777
    SAD CAN; JMP H4         /CANCEL ->
    DAC* A2; ISZ A2
    JMP H5
H4  LAC A2                  /MOVE BACK POINTER
    SAD L2; JMP H5          /UNLESS START OF CARD
    TAD (-1; DAC A2
H5  ISZ WC; JMP H3          /NOT AT END OF DATA ->
H7  JMS .CR                 /WAIT FOR DEVICE
    CRSI; JMP .CR+3         /NOT CR =>
    CROC
    ISZ WC
    SPA!RTR; JMP H9         /ERROR ->
    SNL; JMP H7             /CARD NOT DONE ->
H8  LAW -121; TAD DC; TAD WC
    SZA!STL!CLC; JMP H9     /NOT 80 COLS ->
    DAC* A2
    LAC A2
    SAD L2; JMP .+7
    CLC; TAD A2; DAC A2
    LAC* A2
    SNA!CLC; JMP .-11
    LAC L2; TAD (122        /ADVANCE POINTER
    DAC L2; TAD (-366       /WRAP ROUND
    SAD BS; DAC L2          /IF NECESSARY
    CLC; TAD SLOTS          /DECREMENT COUNT
    DAC SLOTS
    SZA!CLL!CLA; JMP H1
H9  RTL; DAC IND
    JMP .CR+2               /=> SYSTEM
CT  0000; 2202; 0000; 4202; 2102; 1042; 4000; 0022
    4022; 2022; 2042; 4012; 1102; 2000; 4102; 1400
    1000; 0400; 0200; 0100; 0040; 0020; 0010; 0004
    0002; 0001; 0202; 2012; 4042; 0012; 1012; 1006
    0042; 4400; 4200; 4100; 4040; 4020; 4010; 4004
    4002; 4001; 2400; 2200; 2100; 2040; 2020; 2010
    2004; 2002; 2001; 1200; 1100; 1040; 1020; 1010
    1004; 1002; 1001; 0000; 2006; 0000; 0000; 1022
K   -1                      /ACTS AS LONG STOP
CTS CT
LITCR .SIXBT 'CR'
L1;L2;A1;A2
BS;I;SLOTS;WC;IND
GUARD=JMS 3;WAIT=JMP 2;ACCEPT=ISZ 3
.BU=16000;.CR=16010;.MH=16020;.NL=16030
CRSC=706722;CRSI=706721;CROC=706716
 .END
