                                 
                                                             Print event program
                                                             reads active event tape and prints its contents
                                                             by Roberto Sancho Nov 2020
                                 
                                                             tapes input:
                                                                           09 program
                                                                           01 active event tape created in Run 06
                                                                   output
                                                                           02 tansactions to print on ctc
                                                                   on line print:
                                                                              (only 4 words filled with data)
                                                                              label of input tape(s) 
                                                                              nnnn 00000 00 00 | NNN xxx xxxx SCHEDL | xxxxxx  EEEEEEEEE R | TSTS TTTT RS PR AA BB
                                                                              nnnn 00000 01 00 | 00 xxxx PPPPPPPPP x | TE                  | Sigma
                                                                              nnnn 00000 02 00 | 00 xxxx PPPPPPPPP x | TE                  | Sigma
                                                                              nnnn 00000 00 01 | 00 xxxx SSSSSSSSS x | TE                  | Sigma
                                                                              nnnn 00000 00 02 | 00 xxxx SSSSSSSSS x | TE                  | Sigma
                                 
                                                                              nnnn=number of event
                                 
                                                             stops: IC: 01693 (00 61 0000 0000 1696) -> unrecoverable read error
                                                                    IC: 01718 (00 61 1721 0000 1727) -> unrecoverable write error
                                 
                                                                    IC: 00001 (00 61 0000 0000 0000) -> finished ok. 
                                 
                                                             Switch 74 set to off      -> output is printed on online printer 1
                                                                              transfer -> output is written in tape 2
                                 
                                                             Input tape tape event record (as written by Run06) 
                                 
                                                             w1 = NNN xxx xxxx SCHEDL    NNN=event len=7+3*num pred+3*num succ, SCHEDL=Schedulled date (format mm dd yy)
                                                             w2 = xxxxxx  EEEEEEEEE R    EEE=event code, report code      
                                                             w3 = 
                                                             w4 = 
                                                             w5 = 
                                                             w6 = 
                                                             w7 = TSTS TTTT RS PR AA BB  AA=num of predecesors  BB=num of successors  
                                                                                         TTTT=completition date (if event completed, else 0000), 
                                                                                         TSTS=Schedulled completition time, 
                                                                                         RS=Resource Code (=Res.rate), PR=Spec Code (=Pref.Rate)
                                                             w8 = 00 xxxx SSSSSSSSS x    Successor w1 = event code predecessor/successor
                                                             w9 =                        Successor w2 = TE
                                                             w10 =                       Successor w3 = Sigma
                                           
                                                                                         (w8 w9 w10) repeated AA + BB times
                                                                                         depending on how much AA BB pred/successors
                                 
                                 
                                                             in input tape event are grouped in blocks, max 200 words
                                  
                                 
                                 
                                                                                          init
                                 
0008 00 57 0000 0000 0000   0008        57                                           Clear M4 M6 M8
0009 09 98 0000 0000 0000            09 98                                           rewind tape 09 program
0010 00 60 1221 1211 0000               TR       ZERO        EVCOUNT
0011 01 94 1219 1219 0000            01 94       TEMP1       TEMP1       0000        read tape 01 label
0012 00 68 0012 0000 1991               68       *                       REREAD      if tape check Call Re-read
0013 00 80 1219 0001 0000               80       TEMP1       0001                    print label for tape 1
0014 00 80 1221 0002 0000               80       ZERO        0002
0015 00 80 0000 0003 0000               80                   0003
0016 00 80 0000 0004 0000               80                   0004
0017 00 80 0000 0005 0000               80                   0005
0018 00 80 0000 0006 0000               80                   0006
0019 00 81 1221 0007 0000               81       ZERO        0007                    print
                                 
                                                                                          read block from input tape
                                 
0020 01 94 1001 0000 0000   RB-INBUF 01 94       INBUF       0000                    read input block buffer  
0021 00 68 0021 0000 1991               68       *                       REREAD      if tape check Call Re-read
0022 00 67 0000 0000 0080               67                               END         if end of file transfer to end of input 
0023 00 60 0000 1219 0000               TR                   TEMP1                   Temp1=start of block xx xx aaaa bbbb xxxx
0024 04 42 0000 1228 1220            04 MASK                 FIELD-S     TEMP2       Temp2=bbbb=02 90 aaaa bbbb nnnn maked with 0000 0000 1111 0000 -> 0000 0000 bbbb 0000, then shift 4 right to get 0..0 bbbb
0025 08 42 1219 1227 0000            08 MASK     TEMP1       FIELD-R                 REG1=02 90 aaaa bbbb nnnn maked with 0000 1111 0000 0000 -> 0000 aaaa 0000 0000, then shift 8 right to get 0..0 aaaa 
0026 00 41 1220 0000 0000               SUB      TEMP2             
0027 00 40 0000 1222 1203               ADD                  ONE         BL-INBUF    BL-INBUF=Block Len from Input Transaction=bbbb-aaaa+1
0028 00 41 1226 0000 0000               SUB      N200                                check Block Len from Input Transaction
0029 00 63 0031 0031 0000               TR SGN   LSPL3       LSPL3                   transfer if 200 or less
0030 00 61 0000 0000 0000               STOP                                         stop because event block in tape is too big (max 200w)
0031 00 60 1221 1204 0000   LSPL3       TR       ZERO        NW-INBUF                NW-INBUF=Number of words already processed from Input Transaction block
0032 00 60 0000 0000 0033               TR                               RR-INBUF    goto process first event record in block
                                                                                          end of split phase
                                 
                                                                                          read event record from from input tape block 
                                 
0033 00 41 1203 1204 0000   RR-INBUF    SUB      BL-INBUF    NW-INBUF                REG1=words left to be read in input event block. 
0034 00 63 0036 0020 0000               TR SGN   LRR1        RB-INBUF                If no words left, go to read next block
0035 00 61 0000 0000 0000               STOP                                         Safety: stop because overflowing block rec
0036 96 60 1204 0000 0000   LRR1     96 TR       NW-INBUF                            Shift num words read into field S
0037 00 40 1236 0000 0038               ADD      SETM-OP                 LRR2        set instr to ...
0038 00 00 0000 0000 0000   LRR2        00       0000        0000        0000        ... clear modif and set M6=NW-INBUF, M8=NW-OUTBUF
0039 00 60 7001 5212 0000   LRR3        TR       INBUF   +M6 W1      +M4             copy from input tranasction block to rec w1..w7
0040 00 50 0000 0001 0000               50       0000        0001        0000        ... incr M6
0041 00 58 0001 0007 0039               58       0001        0007        LRR3        ... incr M4, loop
0042 00 40 1204 1224 1204               ADD      NW-INBUF    N7          NW-INBUF    Number of words read from block += 7
                                 
                                                                                          get event data 
                                             
0043 00 40 1211 1222 1211               ADD      EVCOUNT     ONE         EVCOUNT     incr total count of events
0044 00 60 1221 1206 0000               TR       ZERO        CODE1
0045 00 60 1221 1207 0000               TR       ZERO        CODE2
0046 00 60 1221 1208 0000               TR       ZERO        CODE3
                                 
0047 00 60 1212 1206 0000               TR       W1          CODE1                   first word of event | NNN xxx xxxx SCHEDL   |
0048 00 60 1213 1207 0000               TR       W2          CODE2                                       | xxxxxx  EEEEEEEEE R   |
0049 00 60 1218 1208 0000               TR       W7          CODE3                                       | TSTS TTTT RS PR AA BB |
0050 88 60 1211 1205 0000            88 TR       EVCOUNT     CODE                    number of event     | nnnn 0000 0000 0000   |
0051 08 60 0051 0000 0082            08 60       *                       PRINT
                                                                                          get predecessors if any
                                              
0052 02 42 1218 1232 1209            02 MASK     W7          AA-FIELD    NPRED       get number of predecessors
0053 00 70 0000 1221 0063   LPRED1      TR EQ                ZERO        LPRED9      if no predecessors, continue
0054 00 60 7001 1206 0000               TR       INBUF   +M6 CODE1                   get predecessor acivity data 
0055 00 60 7002 1207 0000               TR       INBUF2  +M6 CODE2
0056 00 60 7003 1208 0000               TR       INBUF3  +M6 CODE3
0057 00 40 1205 1225 1205               ADD      CODE        N100        CODE        incr num of predecessors
0058 08 60 0058 0000 0082            08 60       *                       PRINT
0059 00 40 1204 1223 1204               ADD      NW-INBUF    N3          NW-INBUF    Number of words read from block += 3
0060 00 50 0000 0003 0000               50       0000        0003        0000        incr M6 += 3
0061 00 41 1209 1222 1209               SUB      NPRED       ONE         NPRED
0062 00 60 0000 0000 0053               TR                               LPRED1
0063 00 42 1205 1234 1205   LPRED9      MASK     CODE        NN-FIELD    CODE        clear code: nnnn 0..0
                                 
                                                                                          get successors if any
                                              
0064 00 42 1218 1233 1210               MASK     W7          BB-FIELD    NSUCC       get number of successors
0065 00 70 0000 1221 0075   LSUCC1      TR EQ                ZERO        LSUCC9      if no successors, continue
0066 00 60 7001 1206 0000               TR       INBUF   +M6 CODE1                   get successors acivity data 
0067 00 60 7002 1207 0000               TR       INBUF2  +M6 CODE2
0068 00 60 7003 1208 0000               TR       INBUF3  +M6 CODE3
0069 00 40 1205 1222 1205               ADD      CODE        ONE         CODE        incr num of successors
0070 08 60 0070 0000 0082            08 60       *                       PRINT
0071 00 40 1204 1223 1204               ADD      NW-INBUF    N3          NW-INBUF    Number of words read from block += 3
0072 00 50 0000 0003 0000               50       0000        0003        0000        incr M6 += 3
0073 00 41 1210 1222 1210               SUB      NSUCC       ONE         NSUCC
0074 00 60 0000 0000 0065               TR                               LSUCC1
0075 00 42 1205 1234 1205   LSUCC9      MASK     CODE        NN-FIELD    CODE        clear code: nnnn 0..0
0076 00 60 0000 0000 0033               TR                               RR-INBUF
                                 
0077 02 91 0000 0000 0000   END-TAP  02 91       0000        0000                    write end of tape   
0078 08 60 0078 0000 1992            08 60       *                       CHKWRT      Call check Write
0079 00 60 1235 0001 0001               TR       STOP-OP     0001        0001        set stop in 0001, transfer to 0001: sucessfull program end                             
                                 
0080 00 74 0000 0000 0077   END         74                               END-TAP     if switch 74 set to transfer, goto save to output tape
0081 00 60 1235 0001 0001               TR       STOP-OP     0001        0001        set stop in 0001, transfer to 0001: sucessfull program end                             
                                 
                                                                                          print event data
                                 
0082 00 40 1996 0000 0091   PRINT       ADD      MK-TR60                 LPRTEX      set and save exit transfer
0083 00 80 1205 0001 0000               80       CODE        0001
0084 00 80 1206 0002 0000               80       CODE1       0002
0085 00 80 1207 0003 0000               80       CODE2       0003
0086 00 80 1208 0004 0000               80       CODE3       0004
0087 00 80 1221 0005 0000               80       ZERO        0005
0088 00 80 0000 0006 0000               80                   0006
0089 00 74 0000 0000 0092               74                               SAVE-TAP    if switch 74 set to transfer, goto save to output tape
0090 00 81 0000 0007 0000               81                   0007
0091 00 00 0000 0000 0000   LPRTEX      00                                           return to caller
                                 
0092 02 91 0001 0004 0000   SAVE-TAP 02 91       0001        0004                    write to tape
0093 08 60 0093 0000 1992            08 60       *                       CHKWRT      Call check Write
0094 00 60 0000 0000 0091               TR                               LPRTEX      
                                 
                                 
1000 00 00 0000 0000 0000   1000                                                     variables
                                 
1001 00 00 0000 0000 0000   INBUF       RES      200                                 block read from input tape 02 or 03
                                 INBUF2      EQU      INBUF       0001 
                                 INBUF3      EQU      INBUF       0002 
                                 
1203 00 00 0000 0000 0000   BL-INBUF                                                 block length
1204 00 00 0000 0000 0000   NW-INBUF                                                 Number of words read from block
                                 
1205 00 00 0000 0000 0000   CODE                                                     predecessor/succesor code as control word for sort
1206 00 00 0000 0000 0000   CODE1
1207 00 00 0000 0000 0000   CODE2
1208 00 00 0000 0000 0000   CODE3
                                 
1209 00 00 0000 0000 0000   NPRED                           
1210 00 00 0000 0000 0000   NSUCC
                                 
1211 00 00 0000 0000 0000   EVCOUNT                                                  count of event
                                 
1212 00 00 0000 0000 0000   W1                                                       input event record                                                   
1213 00 00 0000 0000 0000   W2
1214 00 00 0000 0000 0000   W3
1215 00 00 0000 0000 0000   W4
1216 00 00 0000 0000 0000   W5
1217 00 00 0000 0000 0000   W6
1218 00 00 0000 0000 0000   W7
                                 
1219 00 00 0000 0000 0000   TEMP1
1220 00 00 0000 0000 0000   TEMP2
                                 
1221 00 00 0000 0000 0000   ZERO     00 00       0000        0000        0000
1222 00 00 0000 0000 0001   ONE      00 00       0000        0000        0001
1223 00 00 0000 0000 0003   N3       00 00       0000        0000        0003
1224 00 00 0000 0000 0007   N7       00 00       0000        0000        0007
1225 00 00 0000 0000 0100   N100     00 00       0000        0000        0100
1226 00 00 0000 0000 0200   N200     00 00       0000        0000        0200
                                 
1227 00 00 1111 0000 0000   FIELD-R  00 00       1111        0000        0000
1228 00 00 0000 1111 0000   FIELD-S  00 00       0000        1111        0000  
1229 00 00 0000 0000 1111   FIELD-T  00 00       0000        0000        1111
1230 00 00 0000 0001 0000   ONE-S    00 00       0000        0001        0000
1231 00 00 0011 1111 1110   TR-FIELD 00 00       0011        1111        1110               
1232 00 00 0000 0000 1100   AA-FIELD 00 00       0000        0000        1100
1233 00 00 0000 0000 0011   BB-FIELD 00 00       0000        0000        0011
1234 11 11 0000 0000 0000   NN-FIELD 11 11       0000        0000        0000
                                 
1235 00 61 0000 0000 0000   STOP-OP  00 61       0000        0000        0000        stop opcode
1236 00 57 0000 0000 0000   SETM-OP  00 57       0000        0000        0000        clear M468 and set M468 opcode
1237 00 60 0000 0000 0000   NOP-OP   00 60       0000        0000        0000        
                                 
                                 
                                 
1990 00 00 0000 0000 0000   1990                                                     Library
                                 
                                                                                          Re-read routine. if error persist then stop 
                                                               
1991 00 61 0000 0000 1991   REREAD      STOP                             REREAD      if read error, stop    
                                 
                                                                                          Check write routine. 
                                 
1992 00 40 1996 0000 1994   CHKWRT      ADD      MK-TR60                 LCHKEX      set and save exit transfer
1993 00 68 0000 0000 1995               68                               LCHK1       if tape check goto lchk1
1994 00 00 0000 0000 0000   LCHKEX      00                                           if no tape chek, return to caller
1995 00 61 0000 0000 1995   LCHK1       STOP                             LCHK1       if write error, stop 
1996 00 59 9999 9140 0001   MK-TR60  00 59       9999        9140        0001   
                                      
