.MCALL .MODULE .MODULE DIRSUP,VERSION=03,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 ; ; V02 Was in the 5.6 sources ; ; V03 Tim Shoppa, 9-OCT-1996. Modify CONDAT so it pays ; attention to Epoch bits. Years 1972-2099 come out ; as 72-199. .NLIST .LIST ORIGIN SUPORT ;CG09 ;+ ; Module DIRSUP ; This module contains support subroutines for DIR. ;- .SBTTL CONDAT ;+ ; CONDAT ; This routine converts the RT-11 format date into something usable. ; INPUTS: ; R0 contains the RT-11 format date ; OUTPUTS: ; The current day, month, and year stored in TDAY, TMON, and ; TYEAR. ; R0 is modified ;- XTERNL GBLDAT CONDAT:: MOV R1,-(SP) ;Save R1 MOV R2,-(SP) ; and R2 MOV R0,R1 ;Get the date BIC #177740,R1 ;Clear all but the year MOV R0,R2 ;Get the Epoch ;003 ASR R2 ;Push it around ;003 SWAB R2 ; until we have ;003 BIC #^c140,R2 ; epoch*32 ;003 ADD R2,R1 ;Add it to the year ;003 ADD #72.,R1 ;RT-11 years are -72 MOV R1,TYEAR ;Save the year MOV #32.,R2 ;Divide by 32 CALL DDIV ;This will put the day in the low 5 bits MOV R0,TDAY ;Store it BIC #177740,TDAY ;Get rid of all but the day CALL DDIV ;Now get the month BIC #177760,R0 ;and get rid of the epoch bits ;003 MOV R0,TMON ; and save it MOV (SP)+,R2 ;Restore the registers MOV (SP)+,R1 ; RETURN .SBTTL DDIV- Single precision divide ;+ ; DDIV ; INPUTS: ; R0 = dividend ; R2 = divisor ; OUTPUTS: ; R0 = quotient ; R1 = remainder ; R2 is unchanged ;- DDIV:: MOV #16.,-(SP) ;Push the shift count CLR R1 ;Clear out the remainder 1$: ASL R0 ;Double precision shift ROL R1 ; CMP R2,R1 ;Will the divisor fit? BHI 2$ ;Branch if not SUB R2,R1 ; INC R0 ; 2$: DEC @SP ;Done? BGT 1$ ;Branch if not TST (SP)+ ;Clean the stack RETURN .SBTTL RTOA- Convert 3 RAD50 words to ASCII ;+ ; RTOA ; This routine converts 3 RAD50 words to ASCII. It assumes that the 3 ; words to convert is a filename block, and inserts blanks accordingly. ; INPUTS: ; R0 -> 3 word block ; R1 -> 11 byte block to store the ASCII ; OUTPUTS: ; R1 updated past the end of the ASCII ;- XTERNL <$R50ASC> GBLDAT RTOA:: MOV R0,-(SP) ;Save R0 MOV R2,-(SP) ; and R2 MOV R0,R2 ;Point to the RAD50 to convert MOV (R2)+,R0 ;Get the first word CALL $R50ASC ;Convert it ;CG09 MOV (R2)+,R0 ;Get next word CALL $R50ASC ; and convert it ;CG09 MOVB #BLANK,(R1)+ ;Move in a blank MOV @R2,R0 ;Get the next word CALL $R50ASC ;Convert it ;CG09 MOVB #BLANK,(R1)+ ;Store the final blank MOV (SP)+,R2 ;Restore the registers MOV (SP)+,R0 ; RETURN .SBTTL GETNAM- Convert filename to RAD50 ;+ ; GETNAM ; This routine converts the ASCII stored at CHARS to 3 words of RAD50. ; Called from the magtape and cassette routines to produce pseudo- ; directory entries. ; INPUTS: ; R5 -> to a pseudo-directory entry ; OUTPUTS: ; R0 is modified ; RAD50 is stored in the filename/filetype locations of the ; pseudo-entry. ;- XTERNL <$ASCR50> GBLDAT GETNAM:: MOV R1,-(SP) ;Save R1 ;CG09+ MOV #CHARS,R1 ;R1 -> ASCII CALL $ASCR50 ;Convert it to RAD50 MOV R0,DE.FN1(R5) ;Store it CALL $ASCR50 ;Convert the next 3 characters MOV R0,DE.FN2(R5) ; and store the RAD50 TSTB (R1)+ ;Skip the blank CALL $ASCR50 ;Convert the filetype MOV R0,DE.TYP(R5) ;Save it MOV (SP)+,R1 ;Restore R1 ;CG09- RETURN .SBTTL GETNM- Convert 2 ASCII characters to a binary number ;+ ; GETNM ; This routine converts two ASCII characters to a binary number. It assumes ; that the characters really represent a number and does no checking. ; INPUTS: ; R0 -> ASCII characters ; OUTPUTS: ; R0 = Binary number ;- GETNM:: MOV R1,-(SP) ;Save R1 MOVB (R0)+,R1 ;Get the first char SUB #60,R1 ;Make it binary MOV R1,-(SP) ;Save it momemtarily ASL R1 ;*2 ASL R1 ;*4 ADD (SP)+,R1 ;*5 ASL R1 ;*10 MOVB @R0,R0 ;Get the next char ADD R1,R0 ;Add in the 1st value SUB #60,R0 ;Take care of the ASCII'ness MOV (SP)+,R1 ;Restore R1 RETURN .SBTTL GETNUM - Convert ASCII to binary, decimal ;+ ; GETNUM ; ; INPUTS: ; R1 -> buffer holding an ASCII character string ; OUTPUTS: ; R3 contains the binary number ;- GETNUM:: CLR R3 ;R3 will hold the binary result 10$: MOVB (R1)+,R0 ;Move char to R0 SUB #'0,R0 ;Subtract ASCII zero BMI 100$ ;If MI, char is not a number CMP #9.,R0 ;Is it a 9? BLO 100$ ;If not, branch ASL R3 ;Multiply previous result by 2 MOV R3,-(SP) ;Save it ASL R3 ;R3 * 4 ASL R3 ;R3 * 8 ADD (SP)+,R3 ;(R3 * 2) + (R3 * 8) = R3 * 10 ADD R0,R3 ;Add new digit to previous result BR 10$ ;Keep going until end 100$: RETURN .SBTTL SPFUN and SPFUN1- Issue .SPFUN request ;+ ; SPFUN, SPFUN1 ; SPFUN is used to issue .SPFUN's to the cassette handler, and to do ; single block spacing on magtapes. ; SPFUN1 is used to space to tapemarks on magtapes. ; Both assume that a magtape or cassette is open on channel ICHAN. ; CALL: ; JSR R5,SPFUN(1) ; .BYTE 377,code ;code is the .SPFUN code to execute ; OUTPUTS: ; R0 is modified. ;- GBLDAT .ENABL LSB SPFUN1:: MOV #-1,-(SP) ;Space to tapemark entry BR 1$ ; SPFUN:: CLR -(SP) ;Cassette or single MT block spacing entry 1$: MOV #IOAREA,R0 ;Point to the EMT area block MOV #32*400+ICHAN,@R0 ;Move in function and channel MOV #LKBLK,2(R0) ;Error reporting block for magtapes MOV (SP)+,6(R0) ;Word count MOV (R5)+,10(R0) ;.SPFUN code EMT 375 ;Execute it RTS R5 ;And return to caller. .DSABL LSB .SBTTL $SAVRG- Save and restore registers 2-5 ;+ ; $SAVRG ; This routine saves and restores registers 2-5 ; CALL: ; JSR R5,$SAVRG ;- $SAVRG:: MOV R4,-(SP) ;Save register 4 MOV R3,-(SP) ; 3 MOV R2,-(SP) ; 2 MOV R5,-(SP) ;Save the return address MOV 10(SP),R5 ;Restore R5 JSR PC,@(SP)+ ;Co-routine return MOV (SP)+,R2 ;Restore the registers MOV (SP)+,R3 ; MOV (SP)+,R4 ; MOV (SP)+,R5 ; RETURN .END