.TITLE BLOCKR - Subroutine .IDENT /V02.01/ .SBTTL MACRO CALLS ; .MCALL QIOW$,QIOW$C,QIO$C,ALUN$C,ALUN$,DIR$ ; .NLIST BEX .ENABL LC ; These routines are divided into three functions ; MTINI ; 1 - Initialize the program ; Rewind the tape ; Set the buffers up for splitting the data out into individual reocrds ; EBCDIC to ASCII conversion if required ; Skip file ; MTBLOK ; 2 - Get a block of information (includes the error routine) ; MTGET ; 3 - Get record of information ; ; NOTICE: Unit 3 is used for terminal I/O ; .SBTTL MTINI ; ; Format of FORTRAN CALL ; CALL MTINI (TLUN, TNAM, MAXBUF, IBANNR, RECLEN, NUMREC, ; Cont NUMFLD, FROM, TO, COUNT, OUTBUF, RECOUT, EBCDIC, SKPFLE) ; where: ; TLUN is the logical unit number to be used ; TNAM is the logical name of the tape drive, always unit 0 ; MAXBUF is the maximum buffer size that will be required (largest block ; on the tape) ; IBANNR is the number of banner characters in the tape record ; RECLEN is the logical record length ; NUMREC is the number of logical records to a tape record ; NUMFLD is the number of fields to be moved ; FROM is the original position in the logical tape record ; TO is the new postion in the final form ; COUNT is the number of characters to transfer ; OUTBUF - the output buffer - will actually use the location ; RECOUT - the size of the output buffer ; EBCDIC - If this value is 1, the record is in EBCDIC and should ; be converted to ASCII before further processing ; SKPFLE If there is a file header on this tape and should be skipped ; this value should be 1 ; MTINI:: NOP ; ; Attach and rewind the mag tape unit ; ; TAPE=2 MOV #ATTAPE,R0 MOV @2(R5),TLUN MOV TLUN,A.LULU(R0) MOV @4(R5),TNAM MOV TNAM,A.LUNA(R0) DIR$ #ATTAPE ; MOV $DSW,R0 ; MOV #QIOTPE,R0 MOV TLUN,Q.IOLU(R0) MOV #IO.ATT,Q.IOFN(R0) DIR$ #QIOTPE ; MOV $DSW,R0 ; MOVB MTSTAT,R0 MOV R0,@2(R5) BLE MTERR MOV #IO.RWD,Q.IOFN(R0) DIR$ #QIOTPE ; MOV $DSW,R0 ; MOV @6(R5),MAXBUF ; TI==3 ALUN$C TI,TI,0 ; ; Get the number of records in the tape record and the size of each ; then set up the processing on each ; MOV @10(R5),NBANNR MOV @12(R5),RECLEN MOV @14(R5),NRECS ; MOV NRECS,R0 MOV #BFFBFF,R2 MOV #INBUF,R3 MOV NBANNR,R1 ADD R1,R3 MOV RECLEN,R1 20$: MOV R3,(R2)+ ADD R1,R3 SOB R0,20$ ; ; Get the "FROM" locations ; ; First must get the number of fields to be used, they all must match ; MOV @16(R5),R0 MOV R0,NUMFLD MOV 20(R5),R1 MOV #FRMBUF,R2 30$: MOV (R1)+,(R2) DEC (R2)+ SOB R0,30$ ; ; Get the "TO" locations ; MOV NUMFLD,R0 MOV 22(R5),R1 MOV #TOBUF,R2 MOV 26(R5),R3 MOV R3,OUTLOC DEC R3 35$: MOV (R1)+,R4 ADD R3,R4 MOV R4,(R2)+ SOB R0,35$ ; ; Get the quantity desired to move ; MOV NUMFLD,R0 MOV 24(R5),R1 MOV #QUABUF,R2 40$: MOV (R1)+,(R2)+ SOB R0,40$ ; ; FILL OUTBUF WITH BLANKS ; MOVB #' ,R0 MOV @30(R5),R1 MOV R1,RECOUT MOV OUTLOC,R2 10$: MOVB R0,(R2)+ SOB R1,10$ ; ; ; Is the tape EBCDIC? FIND OUT? ; CLR CONVRT TST @32(R5) ;If this is zero, tape is ASCII BEQ 50$ INC CONVRT ; ; Number of files to be skipped? ; 50$: MOV @34(R5),R1 BEQ INITDN MOV #QIOTPE,R0 MOV #IO.SPF,Q.IOFN(R0) MOV R1,Q.IOPL(R0) DIR$ #QIOTPE MOVB MTSTAT,R0 MOV R0,@2(R5) BLE MTERR ; ; INITDN: RTS PC ;Finished the initialization ; ; ; CALL MTBLOK (IERR) ; ; IERR is the return variable for errors ; ; Read the mag-tape ; MTBLOK::NOP MOV #QIOTPE,R0 MOV #IO.RVB,Q.IOFN(R0) MOV #INBUF,Q.IOPL(R0) MOV MAXBUF,Q.IOPL+2(R0) DIR$ #QIOTPE ; MOV $DSW,R0 ; MOVB MTSTAT,R0 MOV R0,@2(R5) BLE MTERR ; ; EVERYTHING IS HUNKY DORY & PEACHY KEEN ; TST CONVRT BEQ 10$ MOV #TRANS,R5 JSR PC,EBCASC 10$: RTS PC ; ; ; CALL MTGET (ISEL) ; ; ISEL - Selected record ; MTGET:: MOV @2(R5),R0 DEC R0 ASL R0 MOV BFFBFF(R0),R4 ; JSR PC,REDO RTS PC ; MTERR: RTS PC .PAGE .SBTTL DATA ; ; The attach and QIO directives ; ATTAPE: ALUN$ 1,MM,0 QIOTPE: QIOW$ IO.RWD,,1,,MTSTAT,,<0,0,0,0,0,0> ; ; Buffer areas needed for the above functions ; TLUN: .WORD 1 TNAM: .ASCII /MM/ MAXBUF: .WORD 1 ; ; ; STATUS BLOCK AREAS AND TEMPORARY DATA LOCATIONS ; NBANNR: .BLKW 1 NRECS: .BLKW 1 RECLEN: .BLKW 1 RECOUT: .BLKW 1 ;Size of output record MTSTAT: .BLKW 2. CONVRT: .BLKW 1. ;CONVERT - CLEARED IF DATA IS ASCII, ELSE CONVERT ;FROM EBCDIC (SOMETHING LIKE THAT??) ;USED AS A TEMPORARY STORAGE FOR OFFSET ADDRESSES ; ; Mag-tape I/O ; INBUF: .BLKB 2750. .EVEN BFFBFF: .BLKW 80. ;Used for setting up the translation buffers OUTLOC: .WORD 132. .EVEN OUTLEN: .BLKW 1 ; ; BUFFER AREAS ; NUMFLD: .WORD 1 FRMBUF: .BLKW 40. TOBUF: .BLKW 40. QUABUF: .BLKW 40. ; ; SET UP FOR FORTRAN SUBROUTINE CALLING SEQUENCE ; TRANS: .WORD 2,INBUF,MAXBUF ; ; PROBLEM DESCRIPTION AREA ; PROBLM: .ASCII <12><15>/ Tape has problems, rewinding tape and exiting / .BYTE 12,15 PRBDSC: .ASCII / / NPROB=.-PROBLM .EVEN ; .PAGE .SBTTL SUBROUTINES ; ; THIS SUBROUTINE IS TO RE-ARRANGE THE INPUT BUFFER TO HOW ; THE OUTPUT BUFFER WILL LOOK ; REDO: MOV R0,-(SP) MOV R1,-(SP) MOV R2,-(SP) MOV R3,-(SP) CLR R0 20$: MOV FRMBUF(R0),R1 BEQ 40$ ADD R4,R1 MOV TOBUF(R0),R2 MOV QUABUF(R0),R3 INC R0 INC R0 30$: MOVB (R1)+,(R2)+ SOB R3,30$ BR 20$ 40$: MOV (SP)+,R3 MOV (SP)+,R2 MOV (SP)+,R1 MOV (SP)+,R0 RTS PC ; .END