/DECTAPE OUTPUT (SCRATCH FILE)
 .LOC 17000
    .SIZE
    .SIXBT 'DT'
    200002                  /OUTPUT
UNIT 1
BLOCK1 2
BC  3
INC 4
DO
    SNL; JMP D6             /CLOSE ->
    SAD .NL; LAC (42       /DQ FOR NL
    TAD (-140; SPA; XOR (-40 /6 BITS
    SNA!CLL; LAC (36        /UP FOR AT
    JMP* GET
D1  DAC I
    CLA
    JMS .BU; DAC DV+3       /GET BUFFER
    LAC LITAA1; DAC SUM     /INITIAL CHECKSUM
    LAC BC; DAC BC1         /BLOCK COUNT (NEG)
    LAC BLOCK1              /FIRST BLOCK
D3  DAC DV+1                /CURRENT BLOCK
    LAC DV+3; DAC CA        /CA = BUFF START
    LAC SUM; DAC* CA        /CHECKSUM IN WORD 0
    ISZ CA                  /BUMP TO WORD 1
    LAW -376; DAC WC        /254[10] DATA WORDS
    LAC I
D4  RCR; RTR; RTR; RTR      /CHAR1 << 12
    DAC* CA
    JMS GET; RTL; RTL; RTL  /CHAR2 << 6
    TAD* CA; DAC* CA
    JMS GET                 /CHAR3
    TAD* CA; DAC* CA
    TAD SUM; DAC SUM
    JMS GET                 /IN CASE EOF
    ISZ CA
    ISZ WC; JMP D4          /BLOCK NOT FULL ->
    ISZ BC1; JMP D5         /FILE NOT FULL ->
    LAC (D8; DAC GET        /FOR RE-ENTRY
    JMP D7
D5  DAC I
    LAC DV+1; TAD INC       /CURRENT + INC
    JMS WRITE
    LAC* CA                 /NEXT BLOCK NUM
    JMP D3
D6  LAC (D1; DAC GET        /FOR RE-ENTRY
    LAC DV+3                /FILE OPEN?
    SNA; JMP D8             /NO ->
    ISZ CA; DZM* CA         /ZERO REST
    ISZ WC; JMP .-3
D7  CLC; JMS WRITE          /LAST BLOCK
    LAC DV+3; JMS .BU       /RELEASE BUFFER
    DZM DV+3                /SET CLOSED
D8  CLL!CLC
    JMP* DO
/COROUTINE
GET D1
    STL
    JMP* DO
/OUTPUT BLOCK
WRITE
    DAC* CA                 /LAST WORD (LINK)
W1  LAC (4000; XOR UNIT     /FUNCTION + UNIT
    DAC DV
    LAC (DV
    GUARD; JMP .DH          /CALL HANDLER
    GUARD                   /WAIT FOR TRANSFER
    LAC DV; SMA!SZA; WAIT
    ION
    SMA!CMA; JMP* WRITE     /OK =>
    GUARD; JMP .MH          /REPORT
    JMP W1
I;CA;WC;SUM;BC1
LITAA1 .SIXBT 'AA1'
DV  0; 0; -400; 0
GUARD=JMS 3;WAIT=JMP 2
.BU=16000;.DH=16010;.MH=16020;.NL=16030
 .END
