.Title Readir - Displays brief default directory ;+ ; ; Written by Kevin Carosso ; ; Harvey Mudd College ; ; Note: this program uses TTYIO to ; do its terminal output. ;- .Library /TOOLS:TTYIO.MLB/ _TTYIODEF .Macro on_error dest,?L blbs r0,L brw dest L: .endm .Psect code,nowrt,exe,shr,pic .Entry start,0 movab @#PIO$GT_DDSTRING,r6 ;Get default directory movzbl (r6)+,eqlnam ;Get the string length movc5 eqlnam,(r6),#00,#64,eqlnam+8 ;Finally...the string moval eqlnam+8,eqlnam+4 ;Store address in descriptor cmpb #^A/[/,eqlnam+8 ;See what delimiter is beql 1$ ;Skip if its a "[" movb #^A/[/,eqlnam+8 ;if not, we use angle brackets locc #^A/>/,eqlnam,eqlnam+8 ;Find the matching delimiter movb #^A/]/,(r1) ;and put in proper one. 1$: locc #^a/,/,eqlnam,eqlnam+8 ;Let's see if its a [1,3] type beql nocomma ;nope...skip it subl3 r0,#5,r6 ;# leading zeros for 2nd half subl3 #eqlnam+8,r1,r7 subl3 r7,#4,r7 ;and for first half movc3 #6,1(r1),(r1)[r6] ;Move 2nd half over movc3 #7,eqlnam+9,eqlnam+9[r7] ;and first half ; (to make room) 10$: sobgeq r6,20$ ;Move in leading zeros brb 30$ 20$: movb #^A/0/,eqlnam+12[r6] ;like so brb 10$ ;Loop for all of 'em 30$: sobgeq r7,40$ ;Repeat for 1st group too brb 50$ 40$: movb #^A/0/,eqlnam+9[r7] brb 30$ 50$: movl #8,eqlnam ;Length of string is eight now movl #7,r6 ;Index to last char clrl r7 ;We will be going to top level brb out nocomma:subl3 #1,eqlnam,r6 ;Index to last char movl eqlnam+4,r1 ;Get the string movl eqlnam,r0 ;and its length clrl r7 ;Clear out for search search: locc #^A/./,r0,(r1) ;Find a "." beql out ;no more of 'em movl r1,r7 ;Save address to period incl r1 ;Skip the period and brb search ;Loop till last "." is found out: movc3 #4,extension,eqlnam+8[r6] ;add the extension addl2 #3,eqlnam ;and increment string length tstl r7 beql toplevl ;Are we at top level? movb delim,(r7) ;Close sfd ref with delimiter brb lookup ;and go lookup the file toplevl:movc3 eqlnam,eqlnam+8,eqlnam+12 ;Make room for [0,0] movc3 #5,zcommaz,eqlnam+8 ;and insert it addl2 #4,eqlnam ;Increment string length lookup: $crelog_s tblflg=#2,lognam=lognam,- eqlnam=eqlnam on_error egress $open fab=dirfab ;Open up the .DIR file on_error egress ;on error...exit $connect rab=dirrab ;and connect to it on_error egress ;on error...exit clrl r8 ;Clear line counter getfil: clrl r6 ;Clear out our registers clrl r7 ; movc5 #0,rec_buffer,#0,#256,rec_buffer ;Clear out record buffer $get rab=dirrab ;Get first record on_error egress ;on error...exit movzbl #3,r6 ;Move to first useful char movzbw rec_buffer[r6],filnam_len ;Save as filename length incl r6 makfil: movtc filnam_len,rec_buffer[r6],#00,- uclc,#73,string ;Get the file name in lc bbc #6,string,10$ ;Skip if its not a lpha bicb2 #^X20,string ;convert first char to upcase 10$: locc #^A/./,filnam_len,string ;Look for the decimal point cmpl r0,#1 ;See how many chars left bleq 20$ ;skip if not enough bbc #6,1(r1),20$ ;Skip if not alphha bicb2 #^X20,1(r1) ;Convert first char to upcase 20$: addw2 filnam_len,r7 ;Increment character counter incw filnam_len ;Now we figure offset in divw3 #2,filnam_len,r6 ;words to get to the addl2 #2,r6 ;first version number vernum: movb #^A/;/,string[r7] ;Separate with ';' incl r7 subl3 r7,#73,.Dstring ;Set up our string descr addl3 #string,r7,.Dstring+4 ;with length and offset movw rec_buffer[r6],version_number $fao_s ctrstr=constr,outlen=strlen,outbuf=.Dstring,- p1=version_number ;convert to ascii acbw #65,strlen,r7,20$ ;Add in len of version # ;and skip to 20$ if it fits bbss #0,first,10$ ;If not first file outstr comma_space ;print the separator ', ' 10$: outstr crlf ;Print a outstr string ;and the file string movc5 #0,string,#0,#73,string ;Clear out the string clrl r7 clrl r8 ;and our counters 20$: addl2 #4,r6 ;Move to next version # tstw rec_buffer[r6] ;and continue till zero bleq 30$ brw vernum 30$: addl2 r7,r8 ;Add string length to line cntr bbsc #0,first,newlin ;See if first file name outstr comma_space ;Write a comma addb2 #2,r8 ;That puts 2 more chars out cmpl r8,#69 ;Line longer than 69 chars? bgtr newlin ;If so go do end of line outstr string ;Write the file string brw getfil ;and return for another file newlin: outstr crlf ;Write a movl r7,r8 ;Set line cntr to file length outstr string ;and write file name out brw getfil ;Go get 'nother one. egress: outstr crlf ;Write a outstr crlf ;and another to look right $close fab=dirfab ;Close the file ret .Psect data_and_bufers,long,wrt,noexe,noshr dirfab: $FAB fnm= dirrab: $RAB fab=dirfab,- ubf=rec_buffer,- usz=rec_buffer_size rec_buffer: .blkb 256 rec_buffer_size=.-rec_buffer first: .byte 1 ;First on line flag constr: .ascid/!UW/ ;FAO control code filnam_len: .word 0 ;Keeps the filename char count version_number: .word 0 strlen: .word 0 ;Will receive FAO string length comma_space: .asciz /, / ;String separator chars delim: .ascii /]/ ;Default directory spec delimiter crlf: .byte 13,10,00 ;a zcommaz: .ascii /[0,0]/ extension: .ascii /.DIR/ ;The file extension .Dstring: .blkl 2 ;Descriptor for STRING string: .blkb 73 ;Filename and version numbers lognam: .ascid /DIRFIL/ ;A descriptor for our logical name eqlnam: .long ;and equivalence name .long .blkb 69 uclc: .byte ^A/?/[^X2E] .ascii /.?0123456789/ .byte ^A/?/[7] .ascii /abcdefghijklmnopqrstuvwxyz/ .byte ^A/?/[37] .End start