.MCALL .MODULE .MODULE DIRSWT,VERSION=05,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. ; DIR (Directory Program) ; ; Revision History ; ; 003 Came with 5.6 sources ; ; 004 9-Oct-1996 Handle both 4- and 2-digit years. ; Tim Shoppa ; ; 005 7-Oct-1998 To prevent confusion between somebody typing in ; two small (1..31) integers for a date when they meant for one of ; them to be a year in the 21st century, flag this as an error. ; Done with high bits in KFLAG, JFLAG, and UFLAG. ; .NLIST .LIST .PSECT SWITCH ;+ ; Module DIRSWT ; These routines are called by DECODE to take care of any flags for ; the switches. The interface is: ; R0 = the value passed by CSI or 0 ; R2 -> flag word for the switch ; R3 = the switch word passed by CSI ; All registers EXCEPT R5 may be destroyed. ;- .SBTTL SWJK- /J and /K ;+ ; SWJK ; This routine takes care of switches J and K. It calls NOVAL to set ; the switch flag value, and then calls SD to handle any date value ; passed to it. ;- XTERNL SWJK:: CALL NOVAL ;Set switch flag CALL SD ;Take care of any date passed RETURN .SBTTL NOVAL- /A, /B, /E, /F, /L, /M, /N, /O, /P, /Q, /R, /T, /U, /V ;+ ; NOVAL ; This routine handles all switches which do not take a value. Any value ; given is ignored. Switches J and K are special cases which are also ; handled here. ;- NOVAL:: MOV SP,@R2 ;Mark the flag RETURN .SBTTL SC- /C ;+ ; SC ; This routine handles the C (/COLUMNS) switch. If a bad value is entered, ; the defaults are used. ;- SC:: MOV R0,@R2 ;Save the passed value BLT 1$ ;Branch if <0 CMP #11,R0 ;Is it to big? BGE 2$ ;Branch if not 1$: CLR @R2 ;Get rid of the bad value 2$: RETURN .SBTTL SG- /G ;+ ; SG ; This routine handles the /G (/BEGIN) option. It determines on which file ; the switch was given, and places the ASCII of that filename in SPATS. ; The directory is not listed until a match on that filename occurs, ; (conditional on /P). ; NOTE: ; If PIP ever implements the volume backup option, this option ; should be made compatable with PIP. ;- XTERNL GBLDAT SG:: MOV SP,@R2 ;Set the flag MOV R3,R0 ;Get the switch word CLRB R0 ;Get rid of the switch ASL R0 ;Get rid of value indicator SWAB R0 ;Put it in the low byte ASL R0 ; *4 ASL R0 ; *10 ADD #FSPEC+10,R0 ;R0 now points at the file the switch ; given on. CMP #FSPEC+40,R0 ;Was it given on an input file? BHIS 1$ ;Branch if so. CLR @R2 ;Else clear the flag. Ignore switch BR 2$ ; and skip the rest 1$: MOV #SPATS,R1 ;Point to storage area CALL RTOA ; and convert 3 words to ASCII TST FSPEC+46 ;Is there a 2nd file spec? BNE 2$ ;Branch if so MOV FSPEC+36,FSPEC+46 ;Else force the same input device MOV #R50STR,FSPEC+50 ; and a "*.*". This is needed MOV #R50STR,FSPEC+54 ; to make the option work properly. 2$: RETURN .SBTTL SD- /D ;+ ; SD ; This routine handles user specified dates for /D, /J, and /K. ; NOTE: ; This routine is called by SWJK. It must not modify R2. ;- XTERNL GBLDAT GBLDAT DAYFLG =100000 ;flag bit for days ;005 MONFLG = 40000 ;flag bit for months ;005 YEAFLG = 20000 ;flag bit for years ;005 ALLFLG =DAYFLG+MONFLG+YEAFLG ;all three flags together ;005 SD:: MOV R2,-(SP) ;Save R2 MOV R4,-(SP) ;Save R4 ;005 CMP #SWK,R2 ;Doing /BEFORE? BNE 10$ ;If not, branch MOV #KFLAG,R4 ;We're doing a "/BEFORE" ;005 CMP (R4),#ALLFLG ;/BEFORE done? (it comes here 3 times) ;005 BEQ 10$ ;If yes, branch MOV #KDATE,R2 ;R2 -> /BEFORE storage area BR 1$ ;Merge below 10$: CMP #SWJ,R2 ;/SINCE wanted? BNE 20$ ;Branch if not MOV #JFLAG,R4 ;We're doing a "/SINCE" ;005 CMP (R4),#ALLFLG ;/SINCE finished? (it comes here 3 times);005 BEQ 20$ ;If yes, branch MOV #JDATE,R2 ;R2 -> /SINCE storage area BR 1$ ;Merge below 20$: MOV #UDATE,R2 ;Point to the /DATE storage area MOV #UFLAG,R4 ;and the "/DATE" flag area ;005 MOV SP,SWD ;Turn /DATE on 1$: TST R3 ;Was a value given? BGE 70$ ;Branch if not. We're through. TST R0 ;Check the value for validity BLE 40$ ;No good. Flag as error ;005 CMP #31.,R0 ;Is it a day? BLT 2$ ;Branch if not TST (R4) ;Were we already given a day? ;005 BMI 40$ ;if so, flag as error ;005 MOV R0,4(R2) ;Else save it BIS #DAYFLG,(R4) ;Mark that we now have a day ;005 BR 70$ ; and return to caller ;Valid years may be between ;004 ;72 and 99 or 1972 and 2099 ;004 2$: CMP #2099.,R0 ;Is it too big for a 4-digit year? ;004 BLT 4$ ;Branch if so ;004 CMP #1972.,R0 ;Is it big enough for a 4-digit year? ;004 BLE 3$ ;Yes, so branch to 4-digit year code ;004 CMP #99.,R0 ;Is it too big for a 2-digit year? ;004 BLT 4$ ;Branch if so ;004 CMP #72.,R0 ;Is it big enough for a 2-digit year? ;004 BLE 310$ ;Yes, branch to 2-digit year code ;004 JMP 40$ ;otherwise illegal number for date ;005 3$: SUB #1900.,R0 ; bring into range 72-199 ;004 310$: BIT #YEAFLG,(R4) ;Did we already have a year? ;005 BNE 40$ ; if so flag as an error ;005 MOV R0,(R2) ;Save it. ;004 BIS #YEAFLG,(R4) ;Mark that we've had a year ;005 BR 70$ ;Return 4$: MOV #MONTHS+2,R3 ;Point to RAD50 month names. CLR R1 ;Initialize counter. 5$: INC R1 ;Bump counter CMP (R3)+,R0 ;Is this one it? BEQ 60$ ;Branch if so TST @R3 ;Anything left? BNE 5$ ;Branch if so 40$: JMP ILCMD ;Else give error. (date no good) 60$: BIT #MONFLG,(R4) ;Did we already have a month ;005 BNE 40$ ; if so flag as error ;005 MOV R1,2(R2) ;Save it BIS #MONFLG,(R4) ;Mark that we've had the month ;005 70$: MOV (SP)+,R4 ;Restore R4 ;005 MOV (SP)+,R2 ;Restore R2 RETURN .SBTTL SS- /S ;+ ; SS ; This routine handles the /S (/SORT) option. It makes sure that the ; specified sort is valid, and if no issues an error message. ;- XTERNL GBLDAT SS:: TST R0 ;Did he want the default? BNE 1$ ;Branch if not MOV SPOS,@R2 ;Sort on position BR 4$ ;Return 1$: MOV #SVAL,R1 ;Point at RAD50 sort options 2$: TST @R1 ;Are we done? BNE 3$ ;Branch if not JMP ILCMD ;Else it's an error 3$: CMP R0,(R1)+ ;Is this one it? BNE 2$ ;Branch if not MOV R0,@R2 ;Else save the value. 4$: RETURN .SBTTL SV- /V[:ONL] ;CG07+ ;+ ; This routine handles the /V[:ONL] (/VOLUMEID[:ONLY] option. If a value ; is specified which is not the RAD50 for "ONL" the Illegal command error ; is given. ;- GBLDAT SV:: MOV R0,SWV ;Did he specify anything? BNE 1$ ;Branch if so INC SWV ;Set the switch BR 2$ ; and return 1$: CMP #^RONL,R0 ;Is it "ONLY"? BEQ 2$ ;Branch if so. Done JMP ILCMD ; else error 2$: RETURN ;CG07- .END