.TITLE PROCESS FILE .IDENT /V1.01/ .NLIST TOC,SYM .ENABL LC ; Part of Sira Paper Tape Punch Despooler. ; ; COPYRIGHT(C) 1981,1982 Sira Institute Ltd., ; South Hill, Chislehurst, Kent, BR7 5EH, England. ; ; Author: C.J. Doran ; ; Assemble as: ; >MAC PPPPROCES=LB:[1,1]RUNMAC/ML,SY:[g,m]PPPPROCES ;+ ; Process file named by the Queue Manager. ; The file is opened and punched in the format specified by FORM. ;- ; MODIFICATIONS RECORD ; ==================== ; V1.01 13-Jul-82 CJD ; Add EIA option. ; Enable file count check if RSX V4. .MCALL SRDA$C,OFNB$R,OFID$R,CLOSE$,DELET$,ASTX$S,GET$ .MCALL QIOW$M,QIOW$R,DIR$ ; Macro to get specified file attributes .MACRO GETATT TYPE,SIZE,ERR MOV #!,RATATT DIR$ #RATQIO,ERR .ENDM GETATT .PSECT CODE,I,RO PROCES::CMPB STATE,#S.FILE ; Waiting for file? BEQ 10$ ; Yes, OK JMP ILLCMD ; No, illegal command in context 10$: MOV #FDB,%0 ; Address FDB for OPEN etc. MOV (%5)+,FDB+F.FNB+N.DVNM ; Copy device name MOVB (%5)+,FDB+F.FNB+N.UNIT ; and unit no MOVB (%5)+,ATTRIB ; Get attributes flag MOV (%5)+,%1 ; and FILUIC MOV #FDB+F.FNB+N.FNAM,%4 ; Address filename entry in FDB MOV (%5)+,(%4)+ ; Copy first filename word (if any?) BNE 15$ ; Yes, must be a file TST @%5 ; No, null filename, or file-ID BNE 30$ ; If 1st word=0 and 2nd<>0, specification by ID ; Open by file name. 15$: MOV %1,FILUIC ; Save UIC for header JSR PC,.WDFUI ; and put it into $$FSR2 MOV #FDB+F.FNB,%1 ; Address filename block JSR PC,.GTDID ; Fill in directory information BCC 20$ ; Branch if OK JSR PC,FCSERR ; Else say FCS error JMP FILDON ; and give up 20$: .REPT 4 ; Copy remaining 4 words of filename MOV (%5)+,(%4)+ .ENDR OFNB$R ; Open for read by filename block BR 40$ ; Go check that it worked ; Open file by file-ID 30$: MOV #FDB+F.FNB+N.FID,%3 ; Address File-ID words .REPT 3 ; 3 to load MOV (%5)+,(%3)+ .ENDR GETATT -5,12,QIOERR ; Get file name MOV #BUFFER,%1 ; Address name words CMP (%5)+,-(%4) ; Adjust pointers: %5->copies, %4->filename .REPT 5 ; Copy 5 words of filename MOV (%1)+,(%4)+ .ENDR GETATT -1,2,QIOERR ; Repeat for owner FILUIC MOV BUFFER,FILUIC ; and save it for header OFID$R ; Open file by ID ; File should be open. 40$: BCC 50$ ; OK if it worked JSR PC,FCSERR ; Else report error JMP FILDON ; and say "done" 50$: JSR PC,READAC ; Make sure user has read access privilege BCC 51$ ; Yes, OK JMP CLOSE ; No, close file immediately 51$: MOVB (%5)+,COPIES ; Get no of copies reqd JSR PC,SETDEF ; Set default form type if required MOVB #S.ACTV,STATE ; File processing now active TSTB FLAGS ; Flag pages reqd? BEQ PCHFIL ; No, don't bother with header info JSR PC,SETFLG ; Yes, set up flag string PCHFLG: JSR PC,PUNFLG ; Punch flag pages ; Punch file. PCHFIL: MOV #CHKSUM,%1 ; Clear checksum block .REPT 4 ; of 4 words CLR (%1)+ .ENDR MOVB #TRUE,LINE1 ; Note we are doing line 1 ; Put in a leader of appropriate characters. ; Restart point for CONTINUE/ALIGN. RUNOUT::JSR PC,DEFAST ; Define AST for receive data interrupts MOV #BUFFER,%1 ; Address buffer MOV #120.,%2 ; Load count MOV %1,%3 ; Copy buffer descriptor for QIO MOV %2,%4 MOVB FORM,%0 ; Get form number 10$: MOVB RUNCHR-1(%0),(%1)+ ; Put appropriate runout char in buffer SOB %2,10$ ; 120. times MOVB #SH.LET,SHIFT ; Sets letter shift for Murray tape ; Punch and read file records until done. PUNCH: QIOW$M PPQIOW,,,,,,,<,%4> ; Put in length first to check BEQ 10$ ; that we don't try to punch 0 bytes (illegal) QIOW$R PPQIOW,,,,,,,<%3> ; Put in buffer address and output BCS 5$ ; Branch if directive call failed MOVB IOSTAT,STPSTA ; Make sure execution was successful BPL 10$ ; Yes, OK 5$: JSR PC,QIOERR ; No, print error message MOV #QM.UPA,%0 ; Say unsolicited pause JMP SNDQMG ; to QMG, and wait for instructions ; Check INTRPT flag to see if the Queue Manager wants to interrupt punching. ; If it is non-zero, an interrupt has occurred, and we return to WAIQMG to ; process it. The only way to get back is via a CONTINUE command, which will ; return either to RESTRT, to begin the file again, or to LFTOFF, here, to ; continue from the next record. 10$: TSTB INTRPT ; Any interrupts? BEQ READ ; No, get next record RTS PC ; Yes, "return" to WAIQMG to see what's wanted LFTOFF::JSR PC,DEFAST ; CONTINUE, re-enable AST READ: GET$ #FDB ; Read a record BCC 10$ ; OK if it worked CMPB FDB+F.ERR,#IE.EOF ; End-of-file? BEQ EOF ; Yes, can handle that JSR PC,FCSERR ; No, report as error BR EOF ; and treat it same as e-o-f 10$: MOV FDB+F.NRBD,%4 ; Get byte count MOV FDB+F.NRBD+2,%3 ; and data address MOV %3,%2 ; Set %2-> ADD %4,%2 ; end of data + 1 MOVB FORM,%1 ; Get form type ASL %1 ; Double form no as pointer JSR PC,@FORMAT-2(%1) ; to table of formatting routines (0 not used) BR PUNCH ; Punch buffer and look for next ; End of file or I/O error. Punch the terminator, runout, and checksum, as reqd. EOF: MOVB FORM,%1 ; Get form type MOV #BUFFER,%5 ; Address buffer space MOVB EOTCHR-1(%1),%0 ; Get end-of-tape character BEQ 5$ ; Ignore if none MOVB %0,(%5)+ ; Start with end-of-tape character JSR PC,UPCSUM ; Include it in checksum 5$: MOV #120.,%2 ; Load count 10$: MOVB RUNCHR-1(%1),(%5)+ ; of runout characters SOB %2,10$ CMPB %1,#F.IMAG ; Image mode? BEQ 20$ ; Yes, that's all CMPB %1,#F.BINA ; Binary mode? BEQ 20$ ; ditto MOV #CHKSUM,%3 ; Address checksum block MOVB #377,(%5)+ ; Text file checksum starts with erase MOV #8.,%2 ; of 8 or 5 bytes CMPB %1,#F.MURR ; Murray? BHI 13$ ; > F.MURR are EIA, 8 bits, but null starter BLO 15$ ; < F.MURR is ASCII, 8 bits required MOV #5,%2 ; Yes, 5 will do ADD #3,%3 ; Skip hi bytes 13$: CLRB -1(%5) ; Checksum starts with null 15$: MOVB (%3)+,%0 ; Get checksum CMPB %1,#F.MURR ; Murray code? BNE 16$ ; No, checksum is right ADD #120.,%0 ; Yes, must include trailer of 120. 37's BIC #^C37,%0 ; and strip all but bits 0-4 16$: MOVB %0,(%5)+ ; Copy checksum character SOB %2,15$ MOV #120.,%2 ; Final leader 17$: CLRB (%5)+ ; of nulls SOB %2,17$ 20$: SUB #BUFFER,%5 ; Compute length QIOW$R PPQIOW,,,,,,,<#BUFFER,%5>,QIOERR ; to punch INCB RPYPKT+Q.MCP ; 1 file copy complete ; End-of-file. ENDFIL: DECB COPIES ; 1 copy done. Is that all? BLE CLOSE ; Yes, go close file ; Restart at top of file, or another copy of the file needed. Rewind it. RESTRT::MOV #FDB,%0 ; Address FDB CLR %1 ; ask for block 0,1 MOV #1,%2 CLR %3 ; Byte 0 JSR PC,.POINT ; Position file pointers TSTB FLAGS ; any "flag pages"? BEQ 10$ JMP PCHFLG ; Yes, go punch them 10$: JMP PCHFIL ; No, do file at once ; Close file on normal completion. If the delete flag is set, delete it ; without further ado. If not, see if a user-written delete routine is ; supplied, and use it if so, otherwise, delete files named PP.* by default. CLOSE: MOV #FDB,%0 ; Address FDB BITB #QP.ADE,ATTRIB ; Delete required? BNE 20$ ; Yes, delete always TST #$DELCK ; No, has user supplied deletion routine? BEQ 10$ ; No, use default criterion JSR PC,$DELCK ; Yes, use it BCS 20$ ; Delete if he sets carry BR 30$ ; Keep if not 10$: CMP FDB+F.FNB+N.FNAM,#^RPP ; Default check. PP.*? BNE 30$ ; No, just close ; Before deleting, make sure we have delete access rights. 20$: BIT #^B1000100010001000,FILACC ; Any relevant delete bit set? BNE 35$ ; Yes, OK to delete MOV #IE.PRI&377,F.ERR(%0) ; No, privilege violation JSR PC,FCSERR ; Tell the caller MOV #FDB,%0 ; Reload FDB address, and just close 30$: CLOSE$ ; Close file BR 40$ 35$: DELET$ ; Delete file 40$: BCC FILDON ; Make sure close worked JSR PC,FCSERR ; Print error message if not ; Tell the queue manager that file is done, and exit. FILDON: MOVB #S.FILE,STATE ; Say waiting for another file .IF GE V$$RSN-40 DEC FILES ; But are any more expected? BNE 10$ ; Yes, OK CLRB STATE ; No, say now idle .ENDC ; File count was sometimes wrong in V3.2 10$: MOV (PC)+,%0 ; Reply is: .BYTE QM.DUN,QM.FIL ; done,file JMP SNDQMG ; Send it to QMG and wait for next command ; Receive data interrupt service routine. Note it in INTRPT, tested at PUNCH ; above. RCVAST: INCB INTRPT ; Note interrupt ASTX$S ; Continue for now ; Subroutine to define AST service routine. DEFAST: SRDA$C RCVAST,CODE,DIRERR ; Define AST, with error check CLRB INTRPT ; Clear interrupted flag IMAGE: RTS PC ; and return .PSECT STATIC,D,RO,LCL .NLIST BEX ; Table of data formatting routines. IMAGE is just a dummy RTS PC (above). FORMAT: ASCII,ASCII,ASCII,ASCII,IMAGE,BINARY,MURRAY,EIA,EIA,EIA,EIA EOTCHR: .BYTE 232,32,32,232,0,0,0,0,0,0;0 ; End-of-tape chars RUNCHR: .BYTE 0,200,0,200,0,0,37,120,20,20,120 ; Runout characters .EVEN .END