.MCALL .MODULE .MODULE DIROUT,VERSION=04,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. ; Edit History: ; ; 001 22-Jul-81 10:34 AM Linda Banche [240,124] ; Fix loss of last char in 513 word listing ; (001) ; ; 003 Was on 5.6 sources ; ; 004 9-Oct-1996 Tim Shoppa ; Fix OUTDAT so that dates are displayed dd-mmm-yyyy ; ;- ; ; DIR (Directory Program) ; .NLIST .LIST ORIGIN OUTPUT ;CG09 ;+ ; ; Module DIROUT ; This module contains the major ruotines which do output for DIR. ; ;- .SBTTL OUTFIL- Output a file entry ;+ ; ; OUTFIL ; This routine formats the output of one file entry, as appropriate ; for the options specified on the command line. ; INPUTS: ; R5 -> directory entry ; CHARS contains the ASCII of the filename ; with blanks at position 7 and 11 ; OUTPUTS: ; R0, R1, and R2 are modified ; ;- XTERNL GBLDAT GBLDAT GBLDAT GBLDAT ;MG01 PROT: .ASCII \P \ ;CG08 .ENABL LSB ;CG09 OUTFIL:: BIT #,@R5 ;Empty file? BEQ 1$ ;Branch if not FORMAT #BUFFER,^$< UNUSED >$ BR 2$ ; 1$: MOVB #'.,CHARS+6 ;Put a '.' in the filename FORMAT #BUFFER,<[S>,<#CHARS,#12> 2$: TST SWF ;Fast listing? BNE 4$ ;Branch if so FORMAT ,< [**>, ;Else print the file length MOVB #40,PROT ;Assume not protected ;CG08+ TST @R5 ;Is it? BPL 21$ ;Branch if not MOVB #'P,PROT ;Flag it 21$: FORMAT ,<[S>,<#PROT,#2> ;Output the protection flag ;CG08- BIT #,@R5 ;Empty file? BEQ 3$ ;Branch if not FORMAT ,<[N11: > ;Put in 11 blanks for the date ;004 BR 4$ ; 3$: MOV DE.DAT(R5),R0 ;Get the file's creation date CALL CONDAT ;Make it useful MOV #TDAY,R0 ;Point the the useful date CALL OUTDAT ;And output it 4$: TST SWB ;Want the starting block number? BEQ 5$ ;Branch if not FORMAT ,< [**>, ;Else put it in the buffer 5$: INC COLCNT ;Bump the number of columns used CMP COLCNT,SWC ;Enough for this line? BLT 6$ ;Branch if not MOVB #CR,(R2)+ ;Else put in a MOVB #LF,(R2)+ ; and a CLR COLCNT ;Clear the used column count MOV SP,NEWLIN ;Say that we don't need a newline BR 8$ ; 6$: MOV #4,R1 ;Figure for a normal listing. ;004 TST SWF ;Is it fast? BEQ 7$ ;Branch if not MOV #2,R1 ;Else put 2 blanks between entries ;004 7$: FORMAT ,<[N*: >, ; CLR NEWLIN ;Say we're working on a line 8$: PRTIT #BUFFER ;Output the buffer RETURN .DSABL LSB ;CG09 .SBTTL CLRBUF- Clear the output buffer ;+ ; ; CLRBUF ; This routine dumps anything left in the output buffer to the output ; file, and closes the output channel. ; ;- XTERNL GBLDAT GBLDAT CLRBUF:: TST DEVTT ;Output going to console? BNE 3$ ;Branch if so. All output done 1$: CLR BUFFER ;Clear a word MOV #512.,R4 ;Set up the count ;001 2$: MOV #BUFFER,R1 ;Get the buffer pointer ;**-1 MOV #1,R2 ;Get the byte count CALL WRITIT ;Go take care of it DEC R4 ;Done? BNE 2$ ;Branch if not 3$: .CLOSE #OCHAN ;Close the output channel BCC 4$ ;No errors...continue ;MG01+ ;+ ;ERROR $ERROR FCP,LEVEL=FATAL,RETURN=NO,FILE=#FSPEC ;- 4$: RETURN ;MG01- .SBTTL OUTDAT- Output a date ;+ ; ; OUTDAT ; This routine outputs a date in DEC standard format: dd-mmm-yyyy ;004 ; INPUTS: ; R0 -> 3 word block containing the day, month, and year. ; OUTPUTS: ; BUFFER contains the ASCIZ string for the date. ; ;- XTERNL <$R50ASC> GBLDAT .ENABL LSB ;CG09 OUTDAT:: MOV R0,-(SP) ;Save R0 MOV R1,-(SP) ; and R1 MOV (R0)+,R1 ;Get the day BEQ 2$ ;Branch if zero CMP #31.,R1 ;Is it valid? BLT 3$ ;Branch if not FORMAT ,<0[D1->, ;Print the day with a leading zero MOV (R0)+,R1 ;Get the month BEQ 1$ ;Branch if no good CMP #12.,R1 ;Is it in range? BLT 1$ ;Branch if not MOV R0,-(SP) ;Save R0 MOV R1,-(SP) ; and R1 MOV R1,R0 ;Get month number ASL R0 ;Make it a word offset MOV MONTHS(R0),R0 ;Get the RAD50 month name MOV R2,R1 ;Store the ASCII in the line buffer CALL $R50ASC ;Convert the month name to ASCII INC R2 ;Bump the buffer pointer BISB #40,(R2)+ ;Make the second character lower case BISB #40,(R2)+ ; and the 3rd character MOV (SP)+,R1 ;Restore the registers MOV (SP)+,R0 ; ADD #1900.,@R0 ;Print 4-digit year ;004 FORMAT ,<-[D>,<@R0> ;Print the year SUB #1900.,@R0 ;Bring year back into 72-199 range ;004 BR 4$ ;Return 1$: SUB #3,R2 ;Bad date... backup buffer pointer BR 3$ 2$: TST (R0)+ ;If a month is there BNE 3$ ; it's a bad date CMP #72.,@R0 ;Was it a zero date? BNE 3$ ;Branch if not FORMAT ,<[N11: > ;Else, no date ;004 BR 4$ ; 3$: FORMAT ,< -BAD- > ;BAD DATE ;004 4$: MOV (SP)+,R1 ;Restore the registers MOV (SP)+,R0 ; RETURN .DSABL LSB ;CG09 .SBTTL WRITIT- Dump the line buffer ;+ ; ; WRITIT ; This routine dumps the line buffer to the output file. ; INPUTS: ; R1 -> line buffer ; R2 = # of characters to dump. ; ;- GBLDAT GBLDAT .ENABL LSB WRITIT:: MOV OLOC,R0 ;Get the output buffer pointer 1$: CMP #OBUF+OUBFSZ,R0 ;Is the buffer full? BHI 4$ ;Branch if not .WRITW #IOAREA,#OCHAN,#OBUF,#OUBFSZ/2,OBLK ;Else write the block BCC 3$ ;Branch if no error ERRWRT:: TSTB @#S$EERR ;What kind of error BNE 2$ ;Branch if hard error ;+ ;ERROR $ERROR OPF,LEVEL=FATAL,RETURN=NO ;Else it's a file full 2$: $ERROR WER,LEVEL=FATAL,RETURN=NO,FILE=#FSPEC ;- 3$: INC OBLK ;Bump the output block count MOV #OBUF,R0 ;Reset the buffer pointer 4$: MOVB (R1)+,(R0)+ ;Move a character into the buffer DEC R2 ;Decrement the character count BNE 1$ ;Branch if not done. TST DEVTT ;Are we outputting to the console? BEQ 5$ ;Branch if not MOVB #200,(R0)+ ;Put in the stopper .PRINT #OBUF ;And print the buffer load MOV #OBUF,R0 ;Reset the pointer 5$: MOV R0,OLOC ;Restore the buffer pointer RETURN .DSABL LSB .END