.MCALL .MODULE .MODULE DIRMT,VERSION=08,COMMENT=,IDENT=NO ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. .SBTTL Abstract and Edit History ;+ ; Module DIRMT (of DIR) ; These routines handle magtape directories. The main routine ; is NEXTMT. It is JMP'ed to from GETFIL. ; ; Edit History: ; ; (004) 02-Jul-91 MBG Fix to allow DIR/DEL of a freshly initialized ; magtape to show a reasonable filename. Also ; corrected CHCKSB to only check for a short read ; if hard error is encountered. ; ; (005) 01-AUG-91 MBG Added error checking after tape positioning ; commands. Added use of some system definitions. ; ; (006) 08-Aug-91 MBG Removed extended error checking as it isn't required ; because 'errors' are expected after tape positioning. ; The 'errors' are BOT/tape mark/EOT indicators. It ; should be an error if we DON'T get an error. Also, ; most tape position is followed by a tape access and ; some error checking, so problems will be caught. ; ; 007 10-Oct-1996 Tim Shoppa ; Allow for years past 2000 in HDR1 to be signalled ; by a leading '0' instead of ' ' before 'YYDDD'. ; ; 008 17-May-1999 Tim Shoppa ; If there is a leading '0', then a 'YY' field ; of '00' doesn't mean invalid year. Move test ; to check for ' 00'. ;- .NLIST .LIST .PSECT MT .SBTTL System definitions .LIBRARY "SRC:SYSTEM.MLB" .MCALL .ERMDF ;Magtape error definitions .ERMDF .MCALL .SFMDF ;Magtape special functions .SFMDF .SBTTL Local data MT.SEQ = 31. ;Offset to file sequence number MT.FID = 4 ;Offset to filename MT.YER = 42. ;Offset to file creation year MT.DAY = 44. ;Offset to file creation day (Julian) MT.FSZ = 54. ;Offset to file size (records) .PSECT IMPURE,D MONTAB: .WORD 31. ;Jan ;This table is used by MTDATE to FEB: .WORD 28. ;Feb ; convert the date on a magtape .WORD 31. ;Mar ; label to RT-11 format. .WORD 30. ;Apr .WORD 31. ;May .WORD 30. ;Jun .WORD 31. ;Jul .WORD 31. ;Aug .WORD 30. ;Sep .WORD 31. ;Oct .WORD 30. ;Nov .WORD 31. ;Dec .SBTTL NEXTMT- Get next magtape filename ;+ ; NEXTMT ; This is the main magtape directory routine. It is JMP'ed to ; from GETFIL. ; INPUTS: ; An HDR label starting at IBUF. ; OUTPUTS: ; R5 -> a pseudo-directory entry at IBUF+1000 ; CHARS contains the filename ; SBLOCK contains the file sequence number ; All registers modified. ;- XTERNL XTERNL GBLDAT GBLDAT GBLDAT GBLDAT .PSECT MT .ENABL LSB NEXTMT:: TST EOSFLG ;Have we encountered EOT or LEOT? BEQ 10$ ;Branch if not .SPFUN #IOAREA,#ICHAN,#SF.MRE,#0,#0,#LKBLK,#1 ;Start a rewind SEC ; say we're done JMP 190$ ; and return with done. 10$: MOV #IBUF+1000,R5 ;Put fake directory entry here. MOV #IBUF,R4 ;Point to input buffer MOV R4,R0 ;Point to filename ADD #MT.FID,R0 ; MOV #CHARS,R1 ;Store the filename here MOV R1,R3 ;Save it. TSTB @R0 ;Deleted file? ;preV3 BEQ 20$ ;Yes... ;preV3 CMPB @R0,#377 ;Deleted file? ;preV3 BNE 30$ ;Branch if not ;preV3 20$: CLR DE.LEN(R5) ;Length is zero MOV #DS.EMP,@R5 ;Empty file BR 110$ ;Go get positioned for next file 30$: MOV #DS.PRM,@R5 ;Make it a permanent entry MOV #13,R2 ;Blank fill the filename area 40$: MOVB #BLANK,(R1)+ ; DEC R2 ; BNE 40$ ;Branch if not MOV #6,R2 ;Filenames are 6 characters long 50$: CMPB @R0,#DOT ; or until the '.' is found BEQ 60$ ;Branch if found MOVB (R0)+,(R3)+ ;Move in the character DEC R2 ;Done? BNE 50$ ;Branch if not 60$: CMPB @R0,#DOT ;Was the last character a '.'? BNE 70$ ;Branch if not TSTB (R0)+ ;Else get rid of it SUB #4,R1 ;Point R1 at the filetype area 70$: MOV #3,R2 ;Move 3 characters ;MG04 80$: CMPB @R0,#DOT ;Is it a dot? ;MG04;CG10 BEQ 90$ ;Branch if so. Done. MOVB (R0)+,(R1)+ ;Move in the character DEC R2 ;Done? BNE 80$ ;Branch if not ;CG10 90$: MOV R4,R1 ;Point to the file sequence number ADD #MT.SEQ,R1 ; CLRB 4(R1) ;Mark the end CALL GETNUM ;Convert it to binary MOV R3,SBLOCK ;Save it BNE 100$ ;It's not an empty... CLR DE.LEN(R5) ;Empty, zero length MOV #DS.EMP,@R5 ; and make it an empty 100$: CALL MTDATE ;Go get the date CALL GETNAM ;Convert the name to RAD50 110$: JSR R5,SPFUN1 ;Space forward to tapemark .BYTE 377,SF.MFS 120$: JSR R5,SPFUN1 ;Again... .BYTE 377,SF.MFS 130$: CALL READMT ;Read a label (we hope) BCC 150$ ;Branch if no error CALL CHCKSB ;Check for a 'short block read' BEQ 150$ ;Branch if so... may be a good label CMP LKBLK,#EM.EOT ;End-of-tape (w/o EOF)? BEQ 140$ ;Yes... CMP LKBLK,#EM.EFT ;Maybe, was it w/EOF? BNE 130$ ;Nope.. 140$: CLR DE.LEN(R5) ;We hit EOT without a label. Zero length BR 180$ ;Finish up 150$: CMP IBUF,#MT.HDR ;Did we get a header label? BNE 160$ ;Branch if not JSR R5,SPFUN1 ;Else do 2 backspaces to tapemark .BYTE 377,SF.MFS ; followed by a space forward JSR R5,SPFUN1 ; and a read .BYTE 377,SF.MFS ; to get to the EOF label BR 120$ ; 160$: CMP IBUF,#MT.EOF ;Did we get the EOF label? BNE 130$ ;Branch if not. Try reading another block BIT #DS.PRM,@R5 ;Is this file there? BEQ 170$ ;Branch if not MOV R4,R1 ;Point to record count ADD #MT.FSZ,R1 ; CLRB 6(R1) ;Mark the end of the field CALL GETNUM ;Go make it binary MOV R3,DE.LEN(R5) ;Save it 170$: JSR R5,SPFUN1 ;Space forward tapemark .BYTE 377,SF.MFS ; CALL READMT ;Read the next label (we hope) BCC 190$ ;Branch if no error CALL CHCKSB ;Short block check. CLC ;Clear carry, just in case BEQ 190$ ;Branch if it was... Ignore error 180$: MOV SP,EOSFLG ;Else assume EOT or LEOT 190$: RETURN .DSABL LSB .SBTTL MTDATE- Convert a magtape date to RT-11 format ;+ ; MTDATE ; This routine converts the date on a magtape label to RT-11 ; format. The magtape date is of the form: ; ' yyddd' ;007 ; where 'yy' is the year mod 100, and ddd is the Julian date. ; If the year .GE. 2000, then the ' ' is replaced by a '0'. ;007 ; ; Note: ; R5 points to simulated directory entry under construction ; ;- XTERNL GBLDAT MTDATE:: MOV R3,-(SP) ;Save R3 MOV R4,R1 ;Point to label ADD #MT.DAY,R1 ;Point to day of creation CLRB 3(R1) ;Mark the end of the field CALL GETNUM ;Convert the number to binary (returned in R3) MOV R4,R0 ;Point to label ADD #MT.YER,R0 ;Point to year of creation CALL GETNM ;Go convert it to binary CMPB (R4),#'0 ;Is it a 20xx year? ;007 BNE 04$ ;Branch if no ;008 ADD #100.,R0 ;Else add another 100. ;007 04$: TST R0 ;Was it ' 00'? ;008 BEQ 10$ ;If so, no valid date ;008 SUB #72.,R0 ;Else put it in RT-11 format 10$: MOV #28.,FEB ;Default is 28 days in FEB BIT #3,R0 ;Is it a leap year? BNE 20$ ;Branch if not INC FEB ;Bump number of days in FEB 20$: MOV #MONTAB,R1 ;Point to the month table 30$: CMP @R1,R3 ;Will it fit? BGE 40$ ;Branch if not. We've found the month it's in SUB (R1)+,R3 ;Else subtract this month's days, bump pointer BR 30$ ;Try again 40$: SUB #MONTAB,R1 ;R1 now = Month *2 +2 TST (R1)+ ;Month *2 TST R3 ;Is there a day? BNE 50$ ;Branch if so CLR R1 ;Else clear the month 50$: ASL R1 ;Make room for the day ASL R1 ; ASL R1 ; ASL R1 ; ADD R3,R1 ;Add in the day ASL R1 ;Now make room for the year ASL R1 ; ASL R1 ; ASL R1 ; ASL R1 ; MOV R0,R3 ;Now we put the age bits into R3 ;007 ASL R3 ;Put them in the right place ;007 SWAB R3 ; ;007 BIC #^c<140000>,R3 ;Clear all but age bits in R3 ;007 BIC #^c<000037>,R0 ;Clear all but year bits in R0 ;007 ADD R3,R1 ;Add in the epoch ;007 ADD R0,R1 ;Add in the year MOV R1,DE.DAT(R5) ;Save the date MOV (SP)+,R3 ;Restore R3 RETURN .SBTTL CHCKSB- Check for a 'short block' read ;+ ; CHCKSB ; This routine checks to see if a magtape read error was caused ; by the record containing less data than requested. If so, ; the Z bit is returned = 1. ;- GBLDAT CHCKSB:: TSTB @#S$EERR ;Was it a hard error? BNE 10$ ;Yes, check it for short read CLZ ;Nope, ensure z-bit is clear BR 20$ 10$: CMP LKBLK,#EM.SML ;Short read error? 20$: RETURN ;*Z* .SBTTL READMT- Read a magtape record ;+ ; READMT ; This routine is called to read magtape records. A .SPFUN is used ; so that the extra information can be obtained. ;- GBLDAT READMT:: .SPFUN #IOAREA,#ICHAN,#SF.MRD,#IBUF,#LABSIZ,#LKBLK RETURN .END