Trailing-Edge
-
PDP-10 Archives
-
decus_20tap5_198111
-
decus/20-0138/tapcop.mac
There are 2 other files named tapcop.mac in the archive. Click here to see a list.
TITLE TAPCOP
SUBTTL TAPE TO TAPE COPY
SEARCH UUOSYM ;USE STANDARD SYMBOLS
COMMENT \
THIS PROGRAM COPIES MAG TAPE FILES FROM ONE MAGTAPE
TO ANOTHER; RECORDS MAY OF VARIABLE LENGTH.
HANDLES INDUSTRY MODE AND EVEN PARITY.
IF BOTH TAPE DRIVES ARE 9-TRACK, BOTH ARE SET TO INDUSTRY MODE.
IF EITHER OR BOTH ARE 7-TRACK, DEC-COMPATIBLE MODE IS USED.
WRITTEN BY HENRIK LIND AND PAUL ALCIERE
\
SALL
TWOSEG
VMAJOR==1
VMINOR==0
VEDIT==4
VWHO==0
.JBVER==137
LOC .JBVER
BYTE (3)VWHO(9)VMAJOR(6)VMINOR(18)VEDIT
;REVISION HISTORY
;001 KENTRON VERSION BY HENRIK LIND
;002 D. O. T. VERSION SLIGHTLY HACKED BY PAUL ALCIERE
;003 Type "[Copying.]" to reassure the user.
;004 TELL THE USER ABOUT THE TAPES HE IS USING.
ICHAN==1 ;INPUT CHANNEL NR
OCHAN==2 ;OUTPUT CHANNEL NR
TTY==3 ;TTY CHANNEL
%DEB==1 ;DEBUG SWITCH
IOCMD==12 ;AC TO HOLD I/O COMMAND FOR DUMP MODE
IOEND==IOCMD+1 ;AC TO HOLD I/O COMMAND TERMINATOR
RELOC 400000 ;HIGH SEGMENT
BEGIN: JFCL
RESET
MOVE 17,[XWD -20,PDL]
OPEN TTY,TTYBLK
HALT
;SET UP LOGICAL NAME OF INPUT MAGTAPE
OUTSTR [ASCIZ"
Input device: "]
MOVE 0,[POINT 6,IDEV+1]
PUSHJ 17,SIXIN ;READ NAME OF INPUT MAGTAPE
MOVSI 0,(SIXBIT/A/) ;DEFAULT DEVICE NAME
SKIPN IDEV+1
MOVEM 0,IDEV+1
;REPORT INPUT MAGTAPE INFO
OUTSTR [ASCIZ/[Input MAGtape: /]
MOVE 1,IDEV+1 ;GET DEVICE NAME
MOVEM 1,LOC ;FOR MTCHR
MOVE 1,[XWD 12,LOC] ;GET INPUT TAPE CHARACTERISTICS
MTCHR. 1,
HALT
TRZE 1,MT.7TR ;TEST FOR 7-TRACK
OUTSTR [ASCIZ/7-track, /]
TRZE 1,MT.WLK ;TEST FOR WRITE-LOCK
OUTSTR [ASCIZ/write-locked, /]
ANDI 1,7 ;TEST DENSITY
OUTSTR [ASCIZ/density: /]
MOVE 0,[DEC 0,200,556,800,1600,6250](1);LOOK UP DENSITY
PUSHJ 17,OUTNUM
OUTSTR [ASCIZ/, reel ID: /]
MOVE 1,LOC+1 ;REEL ID
PUSHJ 17,SIXOUT
OUTSTR [ASCIZ/]
/]
OUTSTR [ASCIZ/
Output device: /]
MOVE 0,[POINT 6,ODEV+1]
PUSHJ 17,SIXIN ;READ NAME OF OUTPUT MAGTAPE
MOVSI 0,(SIXBIT/B/) ;DEFAULT DEVICE NAME
SKIPN ODEV+1
MOVEM 0,ODEV+1
SETZM FILCNT ;CLEAR FILE COUNT
; INIT DEVICES
OPEN OCHAN,ODEV ;OPEN MTA FOR OUTPUT
JRST ERR1 ;ERROR
;REPORT OUTPUT MAGTAPE INFO
OUTSTR [ASCIZ/[Output MAGtape /]
MOVE 0,ODEV+1
MOVEM 0,LOC
MOVE 1,[XWD 12,LOC] ;GET OUTPUT TAPE CHARACTERISTICS
MTCHR. 1,
HALT
TRZE 1,MT.7TR ;TEST FOR 7-TRACK
OUTSTR [ASCIZ/7-track, /]
TRZE 1,MT.WLK ;TEST FOR WRITE-LOCK
OUTSTR [ASCIZ/write-locked, /]
ANDI 1,7 ;TEST DENSITY
OUTSTR [ASCIZ/density: /]
MOVE 0,[DEC 0,200,556,800,1600,6250](1);LOOK UP DENSITY
PUSHJ 17,OUTNUM
OUTSTR [ASCIZ/, reel ID: /]
MOVE 1,LOC+1 ;REEL ID
PUSHJ 17,SIXOUT
OUTSTR [ASCIZ/]
/]
OPEN ICHAN,IDEV ;OPEN MTA FOR INPUT
JRST ERR2 ;ERROR
MOVEI 0,ICHAN ;LOAD CHANNEL NR
MTCHR. 0,
HALT ;ERROR RETURN
TRNE 0,MT.7TR ;IS INPUT DRIVE 7-TRACK?
JRST EPAR ;YES
;INPUT DRIVE IS 9-TRACK
MOVEI 0,OCHAN ;CHECK THE OTHER DRIVE
MTCHR. 0,
HALT
TRNE 0,MT.7TR
JRST RES ;IT IS 7-TRACK
;BOTH DRIVES ARE 9-TRACK
MTIND. ICHAN, ;SET INPUT TO INDUSTRY MODE
MTIND. OCHAN, ;SET OUTPUT TO INDUSTRY MODE
JRST RES
;DETERMINE PARITY FOR 7-TRACK DRIVE
EPAR: OUTSTR [ASCIZ"
Odd parity? (Y/N) "]
PUSHJ 17,TTYIN
CAIN 0,"Y" ;TEST Y/N
JRST RES ;YES
GETSTS ICHAN,1 ;NO
IORI 1,IO.PAR ;SET EVEN PARITY INPUT
SETSTS ICHAN,(1)
GETSTS OCHAN,1
IORI 1,IO.PAR ;SET EVEN PARITY OUTPUT
SETSTS OCHAN,(1)
RES: SETZ IOEND, ;CLEAR COMMAND TERMINATOR
OUTSTR [ASCIZ/
[Copying.]
/]
; BEGIN NEW FILE
FILINI: SETZM NBLOK ;CLEAR BLOCK COUNT
; MAIN PROCESSING LOOP
LOOP: AOS NBLOK ;INCREMENT BLOCK COUNT
IFE %DEB, <
MOVEI 10,^D101
CAMG 10,NBLOK
JRST TERM>
READ: HRRZ IOCMD,.JBFF## ;BUILD I/O COMMAND
SUB IOCMD,.JBREL##
HRLZS IOCMD
HRR IOCMD,.JBFF
SOS IOCMD
IN ICHAN,IOCMD ;INPUT A BUFFER
JRST NWORD ;NEW BUF OK
;ERROR RETURN - CHECK STATUS
GETSTS ICHAN,10 ;GET STATUS OF INPUT UNIT
TRNN 10,700000 ;CHECK FOR ERRORS
JRST CBKT ;NONE, CHECK FOR BKT
OUTSTR [ASCIZ/
%INPUT ERROR AT BLOCK /]
MOVE 0,NBLOK ;LOAD BLOCK COUNT
PUSHJ 17,OUTNUM
PUSHJ 17,STATUS ;DECODE STATUS BITS
;ATTEMPT ERROR RECOVERY
TRZ 10,IO.ERR ;CLEAR ERROR BITS
SETSTS ICHAN,(10) ;TELL MONITOR AND PROCEED
;CHECK FOR BLOCKSIZE TOO BIG - IF SO, GET MORE CORE, BACKSPACE & TRY AGAIN
CBKT: TRNE 10,IO.BKT
JRST BLKBIG ;BLOCKSIZE TOO BIG
TRNE 10,IO.EOF ;CHECK FOR EOF
JRST TERM ;EOF FOUND
TRNE 10,IO.EOT ;CHECK FOR EOT
PUSHJ 17,ENDTAP ;END-OF-REEL PROCEDURE
NWORD: MOVEI 5,ICHAN ;LOAD CHANNEL NR
MTCHR. 5, ;GET WORD COUNT
HALT ;ERROR RETURN
HLRZ 4,5
TRNE 5,MT.NCR ;ANY LEFT OVER CHARS?
AOJ 4, ;YES, NEED EXTRA WORD IN BLOCK
MOVNS 4,4
HRLM 4,IOCMD ;SET OUTPUT WORD COUNT
OUT OCHAN,IOCMD ;OUTPUT A BUFFER
JRST LOOP ;OK - DO MORE
JRST OPTERR ;GO PROCESS OUTPUT ERROR
; CLOSE DEVICES
TERM: CLOSE ICHAN, ;CLOSE INPUT DEVICE
CLOSE OCHAN, ;CLOSE OUTPUT DEVICE
;TEST FOR DOUBLE EOF
MOVE 0,NBLOK ;LOAD BLOCK COUNT
CAIGE 0,2
SKIPG FILCNT ;1ST FILE A SPECIAL CASE
JRST F1
JRST FINI ;LOGICAL END OF TAPE
;OUTPUT ERROR
OPTERR: OUTSTR [ASCIZ/
?OUTPUT ERROR AT BLOCK /]
MOVE 0,NBLOK ;LOAD BLOCK COUNT
PUSHJ 17,OUTNUM ;TYPE IT OUT
GETSTS OCHAN,10 ;GET STATUS INTO AC10
PUSHJ 17,STATUS ;DECODE STATUS BITS
;NOT END OF TAPE
F1: OUTSTR [ASCIZ/
End of file.
File /]
AOS FILCNT ;INCREMENT FILE COUNT
MOVE 0,FILCNT ;LOAD FILE COUNT
PUSHJ 17,OUTNUM ;TYPE OUT DECIMAL NUMBER
OUTSTR [ASCIZ/: /]
MOVE 0,NBLOK ;LOAD BLOCK COUNT
SOJ 0,
PUSHJ 17,OUTNUM ;TYPE OUT DECIMAL NUMBER
OUTSTR [ASCIZ/ blocks copied.
/]
JRST FILINI ;GO PROCESS NEXT FILE
; END OF PROGRAM
TAPFIN: CLOSE ICHAN,
CLOSE OCHAN,
FINI: OUTSTR CRLF
OUTSTR [ASCIZ/[Rewinding]/]
MTREW. OCHAN, ;REWIND MTA
MTREW. ICHAN,
EXIT
; ERROR ROUTINES
ERR1: OUTSTR [ASCIZ/
? Cannot open output device./]
EXIT ;QUIT
ERR2: OUTSTR [ASCIZ/
? Cannot open input device./]
EXIT ;QUIT
BLKBIG: MTBSR. ICHAN, ;BACKSPACE TAPE
MOVE 0,.JBREL
ADDI 0,2000
CORE 0, ;GET MORE CORE
JRST [OUTSTR [ASCIZ/
? Could not get enough core to read tape block.
/]
EXIT]
OUTSTR [ASCIZ/
[/]
MOVE 0,.JBREL ;COMPUTE NEW CORE SIZE
ADDI 0,1001 ;ALLOW FOR WORD 0 AND UPMP
ASH 0,-^D9
PUSHJ 17,OUTNUM ;TYPE OUT LOSEG SIZE
OUTCHR ["+"]
MOVEI 0,HITOP
TRZ 0,400000
ASH 0,-^D9
SKIPE 1
AOS 0 ;ROUND UP
PUSHJ 17,OUTNUM ;TYPE OUT HISEG SIZE
OUTSTR [ASCIZ/P Core.]
/]
JRST READ
CRLF:: BYTE (7) 15,12 ;ASCIZ CR/LF
;END-OF-REEL PROCEDURE:
ENDTAP: MTEOF. OCHAN, ;WRITE TAPE MARK
MTUNL. OCHAN, ;UNLOAD TAPE
OUTSTR NXTAPE ;TELL USER WHAT TO DO
EXIT 1, ;WAIT FOR HIM (HER) TO DO IT
POPJ 17,
NXTAPE: ASCIZ /
Wrote EOF and unloaded.
Use SEND OPR: command to ask operator to mount next reel.
Then give CONTINUE command.
/
; ROUTINE TO INTERPRET FILE STATUS BITS
; COPIED FROM P. ALCIERE, AND MODIFIED SLIGHTLY
; AC 10 CONTAINS FILE STATUS ON ENTRY
DEFINE TESTAT(B,M)
<TRNE 10,1B'B ;;TEST BIT
OUTSTR M ;;TYPE OUT MESSAGE>
STATUS: TESTAT 18,IMPMSG
TESTAT 19,DERMSG
TRNN 10,1B20
JRST .+6
OUTSTR DTEMSG
TESTAT 26,EVNMSG
TDNN 10,[1B26] ;TEST BIT
OUTSTR ODDMSG
TESTAT 22,EOFMSG
TESTAT 23,ACTMSG
TESTAT 24,BOTMSG
TESTAT 29,NRCMSG
OUTSTR CRLF
POPJ 17, ;RETURN
IMPMSG: ASCIZ /
[Tried to write while write-locked, or other illegal operation.]/
DERMSG: ASCIZ /
[Data was missed, tape is bad, or transport is hung.]/
DTEMSG: ASCIZ /
[Parity error.]/
EOFMSG: ASCIZ /
[End of file (or hung device).]/
ACTMSG: ASCIZ /
[Device was active.]/
BOTMSG: ASCIZ /
[Unit is at beginning of tape.]/
EVNMSG: ASCIZ /
[Even parity is set.]/
ODDMSG: ASCIZ /
[Odd parity is set.]/
NRCMSG: ASCIZ /
[Automatic error correction is suppressed.]/
;INPUT FROM TTY AND CONVERT TO SIXBIT
SIXIN: INPUT TTY, ;INPUT ONE LINE INTO TINP
HRRZ 1,0 ;GET ADDRESS FROM POINTER
SETZM @1 ;CLEAR DESTINATION WORD INITIALLY
MOVEI 2,6 ;MAX. 6 CHARACTERS IN DEVICE NAME
GET: ILDB 1,TINP+1 ;PICK UP A LETTER
CAILE 1,140 ;TEST FOR LOWER-CASE
SUBI 1,40 ;IF SO, CONVERT TO UPPER-CASE
CAIN 1,":" ;QUIT ON COLON
POPJ 17,
SUBI 1,40 ;CONVERT TO SIXBIT
JUMPLE 1,CPOPJ ;QUIT ON ANY CONTROL CHARACTER OR BLANK
IDPB 1,0 ;PUT SIXBIT CHARACTER INTO DEVICE NAME
SOJG 2,GET ;LOOP
CPOPJ: POPJ 17,
;CONVERT SIXBIT TO ASCII AND OUTPUT TO TTY
SIXOUT: MOVEI 2,6 ;COUNT 6 CHARACTERS
MOVE 3,[POINT 6,1] ;GET A BYTE POINTER
SIXX: ILDB 4,3 ;PICK UP A SIXBIT CHARACTER
JUMPE 4,CPOPJ ;QUIT ON ZERO
ADDI 4,40 ;CONVERT TO ASCII
OUTCHR 4 ;TYPE OUT ON THE TTY
SOJG 2,SIXX ;LOOP
POPJ 17, ;RETURN
;DECIMAL TYPOUT ROUTINE FROM SYSTEM REFERENCE MANUAL:
OUTNUM: IDIVI 0,^D10 ;DIVIDE BY 10
HRLM 1,(17) ;SAVE REMAINDER
SKIPE 0 ;ALL DIGITS FORMED?
PUSHJ 17,OUTNUM ;NO. CALL SELF RECURSIVELY
HLRZ 0,(17) ;YES. TAKE OUT IN OPPOSITE ORDER
ADDI 0,"0" ;CONVERT TO ASCII
OUTCHR 0 ;TYPE OUT ONE DIGIT
POPJ 17,
;GET A CHARACTER FROM THE TTY. IGNORE NULL, SPACE. CONVERT LC TO UC
TTYIN: INPUT TTY,
TTYIN1: ILDB 0,TINP+1 ;GET THE CHARACTER
JUMPE 0,TTYIN1 ;IGNORE NULL
CAIN 0," " ;TEST FOR SPACE
JRST TTYIN1 ;IGNORE SPACE
CAIL 0,140 ;TEST FOR LOWER CASE
SUBI 0,40 ;CONVERT LOWER CASE TO UPPER CASE
POPJ 17,
LIT
HITOP==.-1 ;HIGHEST ADDRESS IN HIGH SEGMENT
;LOW SEGMENT:
RELOC 0
LOC: BLOCK 12 ;FOR MTCHR
TTYBLK: 0
SIXBIT/TTY/
XWD TOUT,TINP
TOUT: BLOCK 3
TINP: BLOCK 3
FILCNT: 0 ;FILE COUNT
NBLOK: 0 ;NR OF BLOCKS PROCESSED
ODEV: .IODMP ;WRITE DUMP MODE
SIXBIT /B/ ;DEFAULT LOGICAL NAME 'B'
0
IDEV: .IODMP ;READ DUMP MODE
SIXBIT /A/ ;DEFAULT LOGICAL NAME 'A'
0
PDL: BLOCK 20 ;PUSHDOWN LIST
END BEGIN