/DECTAPE OUTPUT (DEC FORMAT)
 .LOC 17000
    .SIZE
    .SIXBT 'DTD'
    200002                  /DT OUTPUT
    .SIXBT 'DTF'            /MUST BE DTF
DOD
    SNL!CLL; JMP D8         /CLOSE ->
    AND (177
    DAC CHAR
    SAD .NL; LAC (15        /CR FOR NL
    JMP* GET                /EXIT FROM CO-ROUTINE
D1  CLC; TAD DOD-1
    DAC CAPOS
    LAW -200; DAC WC        /128 WORD PAIRS
    JMS HEADER
    LAC CHAR; SKP!CLL
D3  JMS GET                 /CHAR1
    RTR; RTR; RTR; RTR
    DAC W1
    JMS GET; RTL; RTL       /CHAR2
    TAD W1; DAC W1
    JMS GET; DAC WL1        /CHAR3
    RAR; RTR; AND (17
    TAD W1; DAC W1
    LAC WL1; AND (7
    CLL; RTR; RTR
    DAC W2
    JMS GET                 /CHAR4
    RTL; RTL; RTL; RTL
    TAD W2; DAC W2
    JMS GET; RAL            /CHAR5
    TAD W2; DAC W2
D4  LAC W1; TAD W2          /ADD TO CHECKSUM
    TAD SUM; DAC SUM
    ISZ WC; JMP D6          /STILL SPACE ->
    LAC HPOS; DAC WL1       /START OF PART-LINE
    LAC* CAPOS; DAC WL2     /END OF PART-LINE
    CLA; JMS PUT            /ODD WORD
    LAC* WL1; DZM* WL1      /CLEAR OLD HEADER
    JMS PUT
    LAC* CAPOS; DAC HPOS
    LAW -177; DAC WC        /RESET COUNT
D5  ISZ WL1; ISZ WC
    LAC* WL1; JMS PUT       /2ND OF PAIR
    LAC WL1                 /FINISHED?
    SAD WL2; JMP D6         /YES ->
    ISZ WL1
    LAC* WL1; JMS PUT       /1ST OF PAIR
    JMP D5
D6  LAC W1; JMS PUT
    LAC W2; JMS PUT
    DZM W2
    LAC* HPOS; TAD (1000    /UPDATED PAIR COUNT
    DAC* HPOS
    SAD (176002; JMP D7     /YES ->
    LAC CHAR                /NEWLINE
    SAD .NL; SKP; JMP D3    /NO ->
D7  DZM CHAR
    CLC; TAD* HPOS
    TAD SUM; CMA
    ISZ HPOS; DAC* HPOS     /CHECKSUM
    JMS HEADER
    JMP D3
D8  LAC CAPOS               /FILE OPEN?
    SNA!CLL!CLC; JMP* DOD   /NO =>
    LAC (1005; DAC* HPOS
    ISZ HPOS
    LAW -1005; DAC* HPOS
    LAC (D1; DAC GET        /FOR RE-ENTRY
    JMP D10
D9  LAC (D9; DAC GET
D10 DZM CAPOS               /INDICATE CLOSED
    CLL!CLC; JMS* DOD-1     /CLOSE DTF
    JMP* DOD
GET D1
    LAC CHAR                /NEWLINE?
    SAD .NL; JMP D4         /YES ->
    STL
    JMP* DOD
PUT
    STL; JMS* DOD-1
    SNL; JMP D9
    JMP* PUT
HEADER
    ISZ WC; JMP H1          /STILL SPACE ->
    CLA; JMS PUT            /ODD WORD
    LAW -177; DAC WC        /RESET COUNT
H1  LAC (1002; JMS PUT      /INITIAL HEADER VALUE
    LAC* CAPOS; DAC HPOS    /HEADER POS
    CLA; JMS PUT            /DUMMY FOR CHECKSUM
    DZM SUM
    JMP* HEADER
CAPOS;HPOS;SUM;CHAR
WL1;WL2;WC;W1;W2
.NL=16000
 .END
