.TITLE REWIND .ENABL LC .SBTTL Documentation .REPT 0 REWind is a program to rewind a tape device. It is intended to be used as an MCR command, such as: >REW MT0: The command structure for rewind is as follows: first, see if there is an MCR command line. If there is not, search RSX for either MT0:, MS0:, MM0:, MF0: or DD0: (in that order) and rewind the tape. The command line, if there is one, is expected to have one of the following formats: >REW n ; Where n is the unit number. As with a null command ; line, REWind searches RSX for the right magnetic tape ; device. >REW dd[n][:] ; Where dd is the device name (e.g., "MT") and n is the ; unit number. If n is not supplied, zero is assumed. .ENDR .SBTTL Definitions and data .IDENT /V0100/ .MCALL EXIT$S,GMCR$,ALUN$S,GLUN$S,QIOW$S,FCSBT$,DIR$ FCSBT$ ; Define bits for use with GLUN$ MTATAB: .ASCII /MT/ ; Table of magnetic tape devices to search for .ASCII /MS/ ; in RSX. The coded order defines which type .ASCII /MM/ ; is searched for first. .ASCII /MF/ .ASCII /DD/ .WORD 0 ; End of list MCRBUF: GMCR$ ; Set up the GETMCR directive block INFO: .BLKW 6 ; Buffer used for GLUN$ and message type out STATUS: .BLKB 4 ; I/O status buffer .NLIST BEX BADDEV: .ASCII /REW -- Invalid device or device specifications/ BDDLEN=.-BADDEV REWERR: .ASCII <12>/REW -- Rewind error; error = / REWLEN=.-REWERR BADCMD: .ASCII /REW -- Illegal command/ BDCLEN=.-BADCMD NOMTA: .ASCII /REW -- Tape drive not in system/ NMTLEN=.-NOMTA .LIST BEX .EVEN .SBTTL Main-line code START: DIR$ #MCRBUF ; Get the MCR command line MOV $DSW,R0 ; Get the number of characters in the line BLE NOCMD ; Jump to default processing if none MOVB #15,MCRBUF+G.MCRB(R0) ; Make sure the terminating character is a ; --this eliminates the check for MOV #MCRBUF+G.MCRB,R5 ; Set up to parse the line NXTCHR: CMPB (R5),#15 ; First skip over the REW. If we BEQ NOCMD ; see a first, stop (although this is CMPB (R5)+,#40 ; an illegal condition). BNE NXTCHR MOVB (R5)+,R1 ; First check to see if this is a command CMPB R1,#'0 ; in the form of "REW n" BLT ILLCMD CMPB R1,#'7 BGT DEVNAM ; If not a number, perhaps a dd[n][:] formm CMPB (R5),#15 ; It is just n, see if that is all on the line BNE ILLCMD ; If not, this is an illegal command SUB #60,R1 ; Convert to binary GETDFT: CALL DFTDEV ; And go find the right mag tape unit BCS BYE ; What? no magtape in this system? JMP REWIND ; Let's go do our job BYE: EXIT$S NOCMD: CLR R1 ; Assume unit 0 JMP GETDFT ; Now go get the default device DSWERR: HALT ; Here if a directive errors out. This ; should never happen after debugging is ; complete. ILLCMD: QIOW$S #IO.WLB,#5,#1,,,,<#BADCMD,#BDCLEN,#40> ; Tell the user the command EXIT$S ; line was bad and exit DEVNAM: CMPB R1,#'A ; Is the character alphabetic? BLT ILLCMD CMPB R1,#'Z BGT ILLCMD MOV R1,R2 ; Yes, save as the first character MOVB (R5)+,R1 ; Get the next character CMPB R1,#'A ; Is this one alphabetic? BLT ILLCMD CMPB R1,#'Z BGT ILLCMD SWAB R1 ; It is, put in left byte and form the ADD R1,R2 ; .ASCII/dd/ in R2 MOVB (R5)+,R1 ; Ok so far, get the next character CMPB R1,#15 ; Is it a ? BEQ UNIT0 ; Yes, go assume unit 0 CMPB R1,#': ; How about a colon? BNE CHKNUM ; No, go see if it is a number CMPB (R5)+,#15 ; Yes, is the command line done? BNE ILLCMD UNIT0: CLR R1 ; The command line didn't have a unit number; JMP ASNLUN ; assume zero ILLDEV: QIOW$S #IO.WLB,#5,#1,,,,<#BADDEV,#BDDLEN,#40> ; Tell the user the system EXIT$S ; didn't recognize the device and exit CHKNUM: CMPB R1,#'0 ; So far we've seen "REW dd", and the next BLT ILLCMD ; character was not a , or colon. This CMPB R1,#'7 ; must be a unit number--check it. BGT ILLCMD CMPB (R5),#15 ; It is; is it followed by a BEQ OKUNIT CMPB (R5)+,#': ; or a colon? BNE ILLCMD CMPB (R5)+,#15 ; Is there anything beyond the "ddn:" BNE ILLCMD ; besides the ? OKUNIT: SUB #60,R1 ; Convert unit number to binary ASNLUN: ALUN$S #1,R2,R1 ; Now get the drive BCS ILLDEV ; No?! GLUN$S #1,#INFO ; Now make sure we can rewind it.... BCS DSWERR BIT #FD.REC,INFO+4 ; Is it a record device? BEQ ILLDEV ; No, can't rewind it REWIND: QIOW$S #IO.RWD,#1,#1,,STATUS ; Rewind it!! BCC CHKSTS JMP DSWERR CHKSTS: MOVB STATUS,R1 ; Check the I/O status BLT NOREW ; Did it work? EXIT$S ; Yes NOREW: QIOW$S #IO.WLB,#5,#1,,,,<#REWERR,#REWLEN> ; Tell the user CLR R0 ; there was an error and the error number BIC #177400,R1 ; Here we have ye old crude 3 octal digit DIV #100,R0 ; print routine ADD #60,R0 MOVB R0,INFO ; Store first byte of error number CLR R0 DIV #10,R0 ADD #60,R0 MOVB R0,INFO+1 ; And the second ADD #60,R1 MOVB R1,INFO+2 ; And the third MOVB #15,INFO+3 ; Now stuff in a QIOW$S #IO.WLB,#5,#1,,,,<#INFO,#4> ; And tell the user EXIT$S ; Bye... .SBTTL DFTDEV ; ; This subroutine takes as argument the unit number in R1 and returns ; with the default mag tape drive assigned to lun 1. The subroutine ; tries to do an assign lun on each device type in the table MTATAB ; until one succeeds. ; DFTDEV: MOV #MTATAB,R3 ; Set up the pointer into the table NXTMTA: MOV (R3)+,R2 ; Get the next tape drive BEQ NOMTA2 ; None left? ALUN$S #1,R2,R1 ; Try to assign it BCS NXTMTA ; Loop if it fails RETURN ; Success, return with C-bit clear NOMTA2: QIOW$S #IO.WLB,#5,#1,,,,<#NOMTA,#NMTLEN,#40> ; Tell the user we lost SEC ; And return with an error RETURN .END START